You are here:  » Site Offline Notice


Site Offline Notice

Submitted by Keeop on Thu, 2009-11-26 07:31 in

Hi David,

I'm having to schedule MySQL restarts on my server every few days or so to improve performance and free up memory. What I'm after is, when MySQL is down, a 'Web site is currently down for maintenance' style message or web page to be displayed. I guess, some quick test to see if a MySQL database is available and if not, redirect to an 'information' web page. Otherwise site visitors are greeted by a rather barren web site!

Any ideas please?

Cheers.
Keeop

Submitted by support on Thu, 2009-11-26 10:26

Hi Keeop,

Sure - as includes/common.php is included on every page; you could add the following code at the end of that script (so that config.php has already been included):

  $link = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword);
  if (!$link)
  {
    header("Location: /offline.php");
    exit();
  }

This won't cause any delay because the connection will be used by the script the first time a call to the database library is made...

Cheers,
David.

Submitted by Keeop on Thu, 2009-11-26 11:11

Thanks David - will give that a go!

Cheers.
Keeop