tags:

views:

53

answers:

2

Is it possible to take a Drupal site offline using Drush?

+6  A: 

Yep. drush vset site_offline 1 will set it offline, then drush vdel site_offline will bring it back.

Alternatively, you can check out my Maintenance File module on drupal.org, which will set your site to offline if it finds a specific file in the directory.

theunraveler
A: 

theunraveler's solution is the best if you're running a single site. We were running a very large multisite drupal installation, with hundreds of sites. Taking them offline that way via drush takes several seconds per site which was unacceptable. The fastest way to take a site offline is to break the db connection by for example renaming the settings.php file. Then just assign a default theme that has a basic template that doesn't require the db, saying "Site Offline" or something. After upgrading you can just repair the settings.php file and you're good to go.

Nader
That takes just as long. To set a default theme for each site, you have to make a database change. The drush command above is also making a change in the database: it is the same as UPDATE {variables} SET value = 1 WHERE name = 'site_offline'. So, the issue is not with drush or even this method of setting sites offline, which is obviously the most ideal.
theunraveler
@theunraveler: I think the point is that you only need to make a single change once you have done the setup. Not a method I would use myself though.
googletorp
@theunraveler: that's not the case. in a multisite setup you can set a default theme in the base installation so that if you can't reach one of the "multisite" sites it defaults to that base theme. trust me i spent a lot of time investigating this including making the db change directly. that's not sufficient because the cache doesn't get flushed. as i mentioned above, i don't recommend this unless you have a lot of sites and performance is important. but with this technique you can take 500 sites offline in a couple seconds, versus 5-7 seconds per site via drush
Nader
nice, my first down vote... :)
Nader
Ah! I didn't know Drupal would fall back to a default theme if it couldn't find the actual theme. Although I still think that the Maintenance File module would be a better option. Good to know, though! +1
theunraveler

related questions