Making site offline - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Making site offline (/showthread.php?tid=15012) |
Making site offline - El Forum - 01-23-2009 [eluser]learnq[/eluser] Hi, I want to whole site go offline when the update script runs via corn job. When the site is updating, ..it should not accept any Mysql query&show;any pages. Is there a easy way to do this in CI ? Making site offline - El Forum - 01-23-2009 [eluser]Ty Bex[/eluser] HIGH LEVEL DETAILS: This is not a perfect solution but it will work. This is only requre a local file read and no db connectivity. 1.) Create a file called "site_status.txt" 2.) The content of the file is a simple "1" for server up and "0" for server down. 3.) Write a library "l_stite_status.php" that opens and reads the value and sets a variable to 1 or 0 "var_site_status" 4.) Autoload the library 5.) In every class or at a higher level with a hook in codeigniter call the library and check if the value is a 1 or 0 6.) If there var_site_status equals 0 then redirect to a site is down for maintenance static html page. Now just have your cron over write a 1 or 0 to the site_status.txt Making site offline - El Forum - 01-23-2009 [eluser]IamPrototype[/eluser] Well, it could easily be done using your database. As an example you create a table called "settings" with some different fields, one of the fields could be "site_status". Then you could code a model and check if "site_status" is "1" (online) or "2" (offline). Auto-load the model and check on every existing page. I don't know if anybody has an easier way to do it. Making site offline - El Forum - 01-23-2009 [eluser]devbro[/eluser] i am not sure if this would help or no but give it a try. in your default application create a custom hook. create either a "pre_controller" or a "post_controller_constructor" this hook would go and check if an update is in progress. if so then kill the request and redirect to a "server is under update" page. just remember that your cron job should reset whatever it is that tells the hook that update is in progress. it can be a temp file or a database record. |