Welcome Guest, Not a member yet? Register   Sign In
How to Shut Down CI App?
#1

[eluser]CodeIgniterNewbie[/eluser]
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?
#2

[eluser]WanWizard[/eluser]
I have a maintenance flag in my configuration (which I load from the database and merge with the config loaded from file).

In my code I test this flag before I restore the user session, so whether or not a user is logged in is not relevant. The next page request hits the maintenance code first.

My cron functions (=module controllers) are all managed by a cron controller, which uses a crontab like database table to determine which jobs to start when, and also logs the state of each job. Only the cron controller itself is started by the OS cron process. So I always know which jobs are currently active, and when they were started. This also allows multiple instances of the cron process, if I want to enable multiple parallel cron processes.




Theme © iAndrew 2016 - Forum software by © MyBB