![]() |
taking down the system - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: taking down the system (/showthread.php?tid=71538) |
taking down the system - richb201 - 08-25-2018 I have a cron job that I will run every Sat night. One of the first things it does is: $_SERVER['MAINT']=1; This creates a $_Server variable and sets it to one. At the end of the cron job I use: $_SERVER['MAINT']=0; echo('done with cron_job'); exit(0); This correctly sets the MAINT to zero and exits. But when a user brings up my main application, in the index() I have: if ($_SERVER['MAINT']==1) { show_error("The Substantiator is down for weekly maintanance. ",500,"System down"); exit(0); } This is not working. When I stop with the debugger on the line above and look for $_Server['MAINT']==1, it doesn't exist. This causes a real error instead of the fake one I am trying to create. I thought the $_SERVER variable is global on the Apache. What am I doing wrong? Rich RE: taking down the system - ragingTorch - 08-25-2018 I haven't played with setting variables in _SERVER global in this manner nor have I seen it in the wild. You could go with a lock file solution to track when the cron starts and ends for your other files Along the lines of PHP Code: file_put_contents('cron.lock', time()); In your index, you can do PHP Code: if(file_exists('cron.lock')) RE: taking down the system - richb201 - 08-26-2018 Thanks. Where does cron.lock go? I can't seem to find it. Is it hidden? RE: taking down the system - ragingTorch - 08-26-2018 (08-26-2018, 06:06 AM)richb201 Wrote: Thanks. Where does cron.lock go? I can't seem to find it. Is it hidden?cron.lock is a temp file that will be created by the file_put_contents function and it will be removed once the cron script has finished running. RE: taking down the system - richb201 - 08-26-2018 ok. got it. thx |