开发者

How to set site in maintenance mode trough shell-script?

开发者 https://www.devze.com 2023-01-18 19:21 出处:网络
For my next project I will use automatic deployments with git. I can run a shellscript before and after deployment.

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?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消