You are here

private function BackgroundProcess::doKeepAlive in Background Process 7.2

Re-launch the process if necessary

1 call to BackgroundProcess::doKeepAlive()
BackgroundProcess::shutdown in ./background_process.inc
Shutdown

File

./background_process.inc, line 934
External API short overview

Class

BackgroundProcess
@file

Code

private function doKeepAlive() {
  $this
    ->log(__FUNCTION__);
  if ($this->keepalive && $this->options['dispatcher'] != 'foreground') {
    $this
      ->logDebug(__FUNCTION__);
    $updated = db_update('background_process', array(
      'target' => 'background_process',
    ))
      ->fields(array(
      'options' => serialize($this->options),
      'exec_status' => $this->exec_status,
      'created' => microtime(TRUE),
    ))
      ->condition('pid', $this->pid)
      ->condition('exec_status', BACKGROUND_PROCESS_STATUS_RUNNING)
      ->execute();
    if ($updated) {
      $this->options['keepalive_counter']++;
      $this->exec_status = BACKGROUND_PROCESS_STATUS_LOCKED;
      $this
        ->sendMessage('keepalive');
      $this
        ->dispatch();
      return TRUE;
    }
  }
  return FALSE;
}