{"id":60,"date":"2009-07-14T14:19:15","date_gmt":"2009-07-14T12:19:15","guid":{"rendered":"https:\/\/www.opengis.ch\/?p=60"},"modified":"2020-04-29T16:08:00","modified_gmt":"2020-04-29T14:08:00","slug":"activating-error-503-from-a-shell-script","status":"publish","type":"post","link":"https:\/\/www.opengis.ch\/fr\/2009\/07\/14\/activating-error-503-from-a-shell-script\/","title":{"rendered":"Activating error 503 from a shell script"},"content":{"rendered":"<p>During deployment of a new version of a website you might want to have your server returning an error 503 (temporarily unavailable). You can easily do this by pointing your web folder to a php page that contains this:<!--more--><\/p>\n<pre lang='PHP'>\/\/server_down.php\nheader(\"HTTP\/1.1 503 Service Unavailable\");\necho \"We are deploying a new version of NoSoapNoBubbles, the server is going to be down for a minute.\";<\/pre>\n<p>if your webfolder is linked to another folder with a symlink (as I explained in my previous post <a href=\"https:\/\/www.opengis.ch\/2009\/07\/10\/symfony-project-on-bluehost-shared-hosting\/\">symfony project on bluehost shared hosting<\/a>) then you can just remove the link and add a new one pointing to the folder containing server_down.php. Remember to rename server_down.php index.php or to create an .htaccess file containing <\/p>\n<pre lang='Bash'>DirectoryIndex server_down.php<\/pre>\n<p> so that server_down.php is shown as directory index.<\/p>\n<p>This solution is more than fine, but I needed to access some files during deployment so I decided to use a combination of the approach above and .htaccess. When the web directory (of our dev site) is being wiped out, then I redirect using the link, when the directory is filled but I&rsquo;m running DB tasks I redirect using .htaccess.<\/p>\n<p>Since our deploy tasks are fully automated (happen on svn commit) here how to edit the .htaccess file using SED (stream editor).<br \/>\nActivate redirection:<\/p>\n<pre lang='Bash'>if [ \"$#\" != \"1\" ]; then\n  echo Invalid number of arguments, must be 1. >&2\n  exit 1\nfi\n#\nHTACCESSPATH=$1 #path to the .htaccess file\ncp  $HTACCESSPATH\/.htaccess $HTACCESSPATH\/.htaccessTMP\nsed 's|#*RewriteCond %{REQUEST_URI} !server_down.php$|RewriteCond %{REQUEST_URI} !server_down.php$|' $HTACCESSPATH\/.htaccessTMP > TMPFILE && mv TMPFILE $HTACCESSPATH\/.htaccessTMP\nsed 's|#*RewriteCond %{REQUEST_URI} !always_available.php$|RewriteCond %{REQUEST_URI} !always_available.php$|' $HTACCESSPATH\/.htaccessTMP > TMPFILE && mv TMPFILE $HTACCESSPATH\/.htaccessTMP\nsed 's|#*RewriteRule ^(.*)$ \/server_down.php [L]|RewriteRule ^(.*)$ \/server_down.php [L]|' $HTACCESSPATH\/.htaccessTMP > TMPFILE && mv TMPFILE $HTACCESSPATH\/.htaccessTMP\nmv $HTACCESSPATH\/.htaccessTMP $HTACCESSPATH\/.htaccess<\/code>\nDeactivate redirection:<code>if [ \"$#\" != \"1\" ]; then\n  echo Invalid number of arguments, must be 1. >&2\n  exit 1\nfi\n#\nHTACCESSPATH=$1\ncp  $HTACCESSPATH\/.htaccess $HTACCESSPATH\/.htaccessTMP\nsed 's|RewriteCond %{REQUEST_URI} !server_down.php$|#RewriteCond %{REQUEST_URI} !server_down.php$|' $HTACCESSPATH\/.htaccessTMP > TMPFILE && mv TMPFILE $HTACCESSPATH\/.htaccessTMP\nsed 's|RewriteCond %{REQUEST_URI} !always_available.php$|#RewriteCond %{REQUEST_URI} !always_available.php$|' $HTACCESSPATH\/.htaccessTMP > TMPFILE && mv TMPFILE $HTACCESSPATH\/.htaccessTMP\nsed 's|RewriteRule ^(.*)$ \/server_down.php [L]|#RewriteRule ^(.*)$ \/server_down.php [L]|' $HTACCESSPATH\/.htaccessTMP > TMPFILE && mv TMPFILE $HTACCESSPATH\/.htaccessTMP\nmv $HTACCESSPATH\/.htaccessTMP $HTACCESSPATH\/.htaccess<\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>During deployment of a new version of a website you might want to have your server returning an error 503 (temporarily unavailable). here a solution<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[28],"tags":[125],"class_list":["post-60","post","type-post","status-publish","format-standard","hentry","category-web-development","tag-qgis-org"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":17,"url":"https:\/\/www.opengis.ch\/fr\/2009\/07\/10\/symfony-project-on-bluehost-shared-hosting\/","url_meta":{"origin":60,"position":0},"title":"Symfony project on (bluehost) shared hosting","author":"Marco Bernasocchi","date":"10 juillet 2009","format":false,"excerpt":"set up a working Symfony project (with SVN) on my bluehost shared hosting, this tutorial should work for other hosters with minor changes. What I wanted was to be able of using my account as a development server for a small group of developers that would automatically show the last\u2026","rel":"","context":"Dans &quot;Web Development&quot;","block_context":{"text":"Web Development","link":"https:\/\/www.opengis.ch\/fr\/category\/web-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4497,"url":"https:\/\/www.opengis.ch\/fr\/2009\/07\/02\/installing-redmine-on-bluehost-shared-hosting\/","url_meta":{"origin":60,"position":1},"title":"Installing Redmine on (bluehost) shared hosting","author":"Marco Bernasocchi","date":"2 juillet 2009","format":false,"excerpt":"script to install readmine 0.8.4 on a shared host that offers ruby on rails.","rel":"","context":"Dans &quot;Web Development&quot;","block_context":{"text":"Web Development","link":"https:\/\/www.opengis.ch\/fr\/category\/web-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":12794,"url":"https:\/\/www.opengis.ch\/fr\/2022\/03\/05\/qfield-users-sit-down-we-need-to-talk-about-storage-access-on-android%ef%bf%bc\/","url_meta":{"origin":60,"position":2},"title":"QField Users Sit Down, We Need to Talk About Storage Access on Android","author":"Marco Bernasocchi","date":"5 mars 2022","format":false,"excerpt":"Since November 2021, Google has enforced new storage access limitations for apps published on its Play store which prohibits direct storage access on Android 11 and above forcing QField to adapt and rely on importing projects and datasets to access those.","rel":"","context":"Dans &quot;QField&quot;","block_context":{"text":"QField","link":"https:\/\/www.opengis.ch\/fr\/category\/gis\/qfield\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/03\/import.png?fit=768%2C417&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/03\/import.png?fit=768%2C417&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/03\/import.png?fit=768%2C417&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/03\/import.png?fit=768%2C417&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":11521,"url":"https:\/\/www.opengis.ch\/fr\/2020\/06\/24\/generate-dxf-on-qgis-server\/","url_meta":{"origin":60,"position":3},"title":"Generate DXF on QGIS server","author":"Matthias Kuhn","date":"24 juin 2020","format":false,"excerpt":"Everyone knows QGIS is on the desktop and mobile devices. Many know QGIS is on the web with QGIS server through OGC services. Some know QGIS server has its own extension to generate PDFs. But did you know that QGIS server can also produce DXF files? DXF DXF files are\u2026","rel":"","context":"Dans &quot;Uncategorised&quot;","block_context":{"text":"Uncategorised","link":"https:\/\/www.opengis.ch\/fr\/category\/uncategorised\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2020\/06\/image.png?fit=1200%2C673&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2020\/06\/image.png?fit=1200%2C673&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2020\/06\/image.png?fit=1200%2C673&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2020\/06\/image.png?fit=1200%2C673&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2020\/06\/image.png?fit=1200%2C673&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":15180,"url":"https:\/\/www.opengis.ch\/fr\/2025\/03\/04\/qfield-3-5-fangorn-background-tracking-a-reality\/","url_meta":{"origin":60,"position":4},"title":"QField 3.5 \u201cFangorn\u201d: Background tracking a reality!","author":"Mathieu","date":"4 mars 2025","format":false,"excerpt":"Track positions in the background, even when your device is locked, for more efficient fieldwork. Enjoy seamless WebDAV folder integration, grid decorations, improved QFieldCloud downloads, and new plugin enhancements, that allow for example OpenStreetMap search integration or AI prompting. Big thanks to our sponsors\u2014this release is a game-changer! \ud83d\ude80","rel":"","context":"Dans &quot;GIS&quot;","block_context":{"text":"GIS","link":"https:\/\/www.opengis.ch\/fr\/category\/gis\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/02\/splash.png?fit=1200%2C736&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/02\/splash.png?fit=1200%2C736&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/02\/splash.png?fit=1200%2C736&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/02\/splash.png?fit=1200%2C736&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/02\/splash.png?fit=1200%2C736&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":14415,"url":"https:\/\/www.opengis.ch\/fr\/2024\/05\/28\/the-postgresql-connection-service-file-and-why-we-love-it\/","url_meta":{"origin":60,"position":5},"title":"The PostgreSQL Connection Service File and Why We Love It","author":"Dave Signer","date":"28 mai 2024","format":false,"excerpt":"The PostgreSQL Connection Service File pg_service.conf has existed for quite some time and maybe you have already used it sometimes. We love it, and that is why we built the new QGIS plugin PG service parser hashtag#QGIS plugin. Read more about pg_service usages and the new plugin on our latest\u2026","rel":"","context":"Dans &quot;Interlis&quot;","block_context":{"text":"Interlis","link":"https:\/\/www.opengis.ch\/fr\/category\/gis\/interlis\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2024\/05\/pgserviceparser-1.png?fit=1200%2C750&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2024\/05\/pgserviceparser-1.png?fit=1200%2C750&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2024\/05\/pgserviceparser-1.png?fit=1200%2C750&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2024\/05\/pgserviceparser-1.png?fit=1200%2C750&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2024\/05\/pgserviceparser-1.png?fit=1200%2C750&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"jetpack_shortlink":"https:\/\/wp.me\/pbdBtI-Y","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":1,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":11241,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts\/60\/revisions\/11241"}],"wp:attachment":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}