public function routeSignal($signo) { $exceptions = array(); $handlers = $this->handlers; foreach ($handlers as $key => $handler) { try { if ($handler->canHandleSignal($this, $signo)) { $handler->handleSignal($this, $signo); } } catch (Exception $ex) { $exceptions[] = $ex; } } if ($exceptions) { throw new PhutilAggregateException(pht('Signal handlers raised exceptions while handling "%s".', phutil_get_signal_name($signo))); } switch ($signo) { case SIGTERM: // Normally, PHP doesn't invoke destructors when exiting in response to // a signal. This forces it to do so, so we have a fighting chance of // releasing any locks, leases or resources on our way out. exit(128 + $signo); } }
public function didReceiveTerminalSignal($signo) { if ($this->inAbruptShutdown) { exit(128 + $signo); } $this->inAbruptShutdown = true; $signame = phutil_get_signal_name($signo); if ($signame) { $sigmsg = "Shutting down in response to signal {$signo} ({$signame})."; } else { $sigmsg = "Shutting down in response to signal {$signo}."; } $this->logMessage('EXIT', $sigmsg, $signo); @fflush(STDOUT); @fflush(STDERR); @fclose(STDOUT); @fclose(STDERR); $this->annihilateProcessGroup(); $this->dispatchEvent(self::EVENT_WILL_EXIT); exit(128 + $signo); }
public final function cleanup($signo = null) { global $g_future; if ($g_future) { $g_future->resolveKill(); $g_future = null; } Filesystem::remove($this->getPIDPath()); if ($signo !== null) { $signame = phutil_get_signal_name($signo); error_log("Caught signal {$signame}, exiting."); } exit(1); }
public function didReceiveTerminalSignal($signo) { $signame = phutil_get_signal_name($signo); if ($signame) { $sigmsg = pht('Shutting down in response to signal %s (%s).', $signo, $signame); } else { $sigmsg = pht('Shutting down in response to signal %s.', $signo); } $this->logMessage('EXIT', $sigmsg, $signo); $this->annihilateProcessGroup(); $this->dispatchEvent(self::EVENT_WILL_EXIT); }
private static function didCatchSignal($signo) { $signame = phutil_get_signal_name($signo); fprintf(STDERR, "%s Caught signal %s (%s).\n", '<SGNL>', $signo, $signame); }
public function didReceiveTerminalSignal($signo) { $this->shouldShutdown = true; $this->shouldRestart = false; $signame = phutil_get_signal_name($signo); if ($signame) { $sigmsg = pht('Shutting down in response to signal %s (%s).', $signo, $signame); } else { $sigmsg = pht('Shutting down in response to signal %s.', $signo); } $this->logMessage('EXIT', $sigmsg, $signo); $this->annihilateProcessGroup(); }