drupal development. drupal support. drupal training.

Follow SystemSeed on:

Do it with Drupal

The Seed Feed

Drupal has a special maintenance mode setting, which should always be used when deploying updates, or making substantial changes. This special maintenance mode can easily be activated via the admin interface at /admin/config/development/maintenance. But that's a bit clunky and slow, especially if you have a lot of sites that you need to put into maintenance mode.

If you're comfortable with the command line, this can easily be done using drush (the Drupal shell). For each site that you want to take offline, run the following commands to enable maintenance mode (where 'example.com' is replaced by the fully qualified domain name of the site that you want to take offline).

$ drush @example.com vset --exact maintenance_mode 1 -y

There is one potential issue with this, which is that the drupal cache is still active, even when in maintenance mode. That means that even after taking the site into maintenance mode, unauthenticated users will still be able to access cached pages. This may or may not be a bad thing depending on what you are trying to achieve, but certainly in the majority of cases it most likely that when you put a site into maintenance mode you want it to appear offline immediately. This issue with the cache in maintenance mode is discussed in some detail here, but the only true way to get around this is to also force a cache after going into and coming out of maintenance mode.

# Put site example.com into maintenance mode.
$ drush @example.com vset --exact --yes maintenance_mode 1
$ drush @example.com cc all

# Take site example.com out of maintenance mode.
$ drush @example.com vset --exact --yes maintenance_mode 0
$ drush @example.com cc all

Including the cache flush like this will be substantially slower because flushing all of Drupal's many cache layers can take some time, especially with a large site. However, it will ensure that the site is brought fully into and out of maintenance mode, and that all users will see the maintenance page or website immediately and the same time.

Note: Of you are using Drupal 6, the 'maintenance_mode' variable is actually called 'site_offline'.

After years of developing all types of web solutions, Tom made the strategic decision to focus his efforts into making Drupal a better platform. In 2010, he led the successful exit of his KirkDesigns through a joint venture with Web at Ease. That event formed SystemSeed.