开发者

How to Shut Down CodeIgniter Application?

Assume I have a CI app that does the following:

  • Allow users to log in and perform certain tasks
  • Constantly have cron running scripts in the background

Now, say I need to do some upgrades to the site. How do I do this safely? I don’t want to shut down the server while users are logged in or cron script still running.

I could set a flag in the DB so that the login page will no longer let people log in. This flag can also be used to tell cron script to stop running more processes. The problem is how do I know if there are still users logged in or 开发者_JAVA百科scripts still running in the background?


What I would do is set a .htaccess file to redirect ALL users no matter what URL they are trying to visit to a maintanance.html.

Here is an example

EDIT:

Oh sorry... I forgot to do the cron jobs. If you are using linux you can output the crontab to a temp file then remove the cron tab so it will not run. When you are finished with the upgrade you can then move the temp file back to the crontab

crontab -l > crontab_file

crontab -r

crontab crontab_file


I have not tested either of these solutions but have noted a few pages that suggestion some ideas of how to go about solving your problem.

  • [Best practice] Maintenance page (htaccess rewrite rules)
  • Code Igniter out of service page


I just use my index.php file. My apps are located in an upper directory, so I might have an application called "maintenance". Then i just change this:

$application_folder = "appname";

to this:

$application_folder = "maintenance";

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜