0

One of my sites went down with the following mysql server down message:

enter image description here

How can I show a basic static page when something fatal like this happens? Are there any modules that do this already? What are some other solutions if a site goes out. I tried cloudflare, but they don't already detect the site going down and still show a fatal message. It would be good if users were shown a static page instead.

  • "Are there any modules that do this already? " - Not really possible. List of enabled modules is in database. When database goes down, Drupal can't know you enabled module to handle this situation. – Mołot Sep 18 '14 at 16:33
  • See here: How to change my maintenance page? - would it help? Is this what you want? I'm not quite sure, but I was under impression that Drupal uses Maintenance Mode theme in situations like this, too. – Mołot Sep 18 '14 at 16:36
  • I think a possible solution is to code a static page on that page that throws the cannot connect to mysql error. Possibly write a js script that detects that type of message only on that page. The script would only be loaded on that specific page. – Patoshi パトシ Sep 19 '14 at 3:09
1

Because Drupal is completely unresponsive when this happens, it's not something you can fix within Drupal.

Setting a static fail page is possible within your web server - most likely Nginx or Apache. If you are using a CDN, you can also configure it to display only cached versions of your pages if your server is unresponsive.

You'll have to consult your server documentation to get your answer.

| improve this answer | |
1

In errors.inc line 245 there is this line:

print theme('maintenance_page', array('content' => t('The website encountered an unexpected error. Please try again later.'))); 

And in theme.inc I see this:

/**
 * Process variables for maintenance-page.tpl.php.
 *
 * The variables array generated here is a mirror of
 * template_preprocess_page(). This preprocessor will run its course when
 * theme_maintenance_page() is invoked. An alternate template file of
 * maintenance-page--offline.tpl.php can be used when the database is offline to
 * hide errors and completely replace the content.
 *
 * The $variables array contains the following arguments:
 * - $content
 *
 * @see maintenance-page.tpl.php
 */

So it seems you can use a template file to customize the error.

| improve this answer | |
0

Drupal's default .htaccess has a section, something like:

# Set the default handler.
DirectoryIndex index.php index.html index.htm

The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory by specifying a / at the end of the directory name. Local-url is the (%-encoded) URL of a document on the server relative to the requested directory; it is usually the name of a file in the directory. Several URLs may be given, in which case the server will return the first one that it finds. If none of the resources exist and the Indexes option is set, the server will generate its own listing of the directory.

so, by default it looks first for index.php - which it finds, but Drupal has errors and gives you that screen. One option is to change this behaviour like this:

# Set the default handler.
DirectoryIndex index.html index.php index.htm

By switching the first two entries around, you can accomplish a manual override by including an index.html file in the root directory. When the site is up and running, simply remove the index.html (or rename it) and it will move on to index.php (drupal). If there's an error and the entire site is down, add your index.html and it will bypass Drupal entirely. Of course, you will have to actually write an index.html and store it somewhere.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.