12

drush @mysite cget system.maintenance shows:

message: '@mysite is currently under maintenance. We should be back shortly. Thank you for your patience.' langcode: en

Drupal 8 uses state values to record transient state, so drush @mysite sget system.maintenance_mode gives me a 1 or a 0.

But, try as I may, I cannot see how to set the boolean. I've tried:

$ drush @mysite sset system.maintenance.mode "TRUE" --format=boolean
$ drush @mysite sget system.maintenance_mode
0
$ drush @mysite sset system.maintenance.mode "TRUE" --format=auto
$ drush @mysite sget system.maintenance_mode
0
$ drush @mysite sset system.maintenance.mode true --format=auto
$ drush @mysite sget system.maintenance_mode
0
$ drush @mysite sset system.maintenance.mode true --format=boolean
$ drush @mysite sget system.maintenance_mode 
0  

What's the secret?

0

1 Answer 1

29

system.maintenance_mode is not a boolean, it is an integer:

drush ev "var_dump(\Drupal::state()->get('system.maintenance_mode'));"

Result:

int(0)

The answer to the question, how to use drush to put a site in maintenance mode:

drush sset system.maintenance_mode 1
2
  • 3
    It's worth noting here that if the site has never BEEN in maintenance mode before, the system.maintenance_mode variable doesn't exist, and the above drush ev command actually returns bool(false), which is misleading. Dec 7, 2017 at 18:42
  • @DaleAnderson can you update the answer to be "mo betta"? May 10, 2019 at 16:45

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