You are here

public function BackgroundProcess::shutdown in Background Process 7.2

Shutdown

2 calls to BackgroundProcess::shutdown()
BackgroundProcess::execute in ./background_process.inc
Execute the background process callback function.
BackgroundProcess::reDispatch in ./background_process.inc
If process has been locked for more than 10 seconds without starting then dispatch it again.

File

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

Class

BackgroundProcess
@file

Code

public function shutdown() {
  $this
    ->logDebug(__FUNCTION__ . " : {$this->shutdown}");
  try {
    $this
      ->writeData();
  } catch (Exception $e) {

    // During shutdown, let's ignore DB errors, so shutdown handler may
    // pickup errors, etc. But we won't restart the process.
    $this
      ->keepAlive(FALSE);
    $this
      ->log((string) $e, WATCHDOG_ERROR);
  }

  // Inform shutdown handlers when done.
  if ($this->shutdown) {
    $this
      ->logDebug('shutting down!');

    // @todo Bump bootstrap level?
    if (function_exists('module_invoke_all')) {
      $this
        ->logDebug('invoking shutdown handlers');
      $this->start = $this->start_stamp;
      module_invoke_all('background_process_shutdown', $this);
    }
    $this
      ->logDebug('calling shutdown callbacks');
    foreach ($this
      ->getShutdownCallbacks() as $info) {
      list($callback, $args) = $info;
      $args[] = $this;
      call_user_func_array($callback, $args);
    }
    $this->shutdown = FALSE;
    return $this
      ->doKeepAlive() ? TRUE : $this
      ->remove();
  }
  return $this
    ->remove();
}