views:

71

answers:

3

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 scripts still running in the background?

Suggestions?

+3  A: 

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
jostster
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 crontabcrontab -l > crontab_filecrontab -rcrontab crontab_file
jostster
A: 

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.

Malachi
A: 

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";

Matthew