You are here

function drush_acsf_go_offline in Acquia Cloud Site Factory Connector 8

Command callback. Puts a site into maintenance.

File

./acsf.drush.inc, line 279
Provides drush commands for site related operations.

Code

function drush_acsf_go_offline() {
  $lock = \Drupal::lock();
  $acsf_settings = \Drupal::configFactory()
    ->getEditable('acsf.settings');

  // Track if a site admin purposely put their site into maintenance.
  $maintenance_mode = \Drupal::state()
    ->get('system.maintenance_mode');
  if ($maintenance_mode) {

    // Site is in maintenance mode already. We need to keep that in mind.
    $acsf_settings
      ->set('site_owner_maintenance_mode', TRUE)
      ->save();
  }

  // For now hard-code a 10 minute expected offline time.
  $expected = time() + 10 * 60;
  \Drupal::state()
    ->set('system.maintenance_mode', TRUE);
  $acsf_settings
    ->set('maintenance_time', $expected)
    ->save();

  // Get the cron lock to prevent cron from running during an update.
  // Use a large lock timeout because an update can take a long time.
  // All cron processes are stopped before update begins, so the lock will
  // be available.
  $lock
    ->acquire('cron', 1200.0);
}