You are here

function background_process_dispatcher_drush in Background Process 7.2

Dispatcher for Drush

1 string reference to 'background_process_dispatcher_drush'
background_process_background_process_dispatcher_info in ./background_process.module
Implements background_process_dispatcher_info().

File

./background_process.dispatchers.inc, line 56

Code

function background_process_dispatcher_drush($process) {
  $service_hosts = background_process_get_service_hosts();
  $service_host = $service_hosts[$process
    ->getServiceHost()];
  $cmd = !empty($service_host['drush_cmd']) ? $service_host['drush_cmd'] : variable_get('background_process_drush_cmd', BACKGROUND_PROCESS_DRUSH_CMD);
  if (!empty($service_host['site_alias'])) {
    $cmd .= ' @' . $service_host['site_alias'];
  }
  $logfile = '/dev/null';
  $logfile = '/tmp/drupal-drush.log';
  $realcmd = "{$cmd} bgp-execute " . escapeshellarg($process
    ->getPID()) . " >> " . escapeshellarg($logfile) . " 2>&1 &";

  #error_log($realcmd);

  #$start = microtime(TRUE);
  exec($realcmd);

  #$end = microtime(TRUE);

  #error_log(sprintf("exec() took %.08f seconds", $end - $start));
  $process->connection = TRUE;
}