views:

12

answers:

1

For my next project I will use automatic deployments with git. I can run a shellscript before and after deployment. Is it possible to set "maintenance" automatically with shell?

In my .htaccess then I would check if a server variable is set to deployment or not to do the rewrite to maintenance?

Is this possible and how should I handle this?

A: 

You could have the .htaccess check for the existence of a file with a certain name, and if it exists, redirect to a static "please hold" page. Then, in your before script, to put the site into maintenance mode, you just touch the file. In your after script, rm it.

Example:

RewriteCond /path/to/maintmode -f
RewriteRule ^(.*)$ maintpage.htm?frompage=$1 [L]

So, to put your app in maintenance mode, do:

touch /path/to/maintmode

To restore to live mode:

rm /path/to/maintmode
Alex Howansky
What If the maintenance page isn't just "Sorry, down for ..." but a full HTML page with CSS, Images, ...
Jonas De Smet
Same thing, doesn't matter. Just use the existence of the file as the trigger for the redirect, it doesn't matter how simple/complex the target page is.
Alex Howansky