• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making site offline

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 ?

[eluser]Ty Bex[/eluser]

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

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. Smile

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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.