Changeset View
Changeset View
Standalone View
Standalone View
src/daemon/PhutilDaemonHandle.php
Show All 12 Lines | final class PhutilDaemonHandle extends Phobject { | ||||
private $argv; | private $argv; | ||||
private $config; | private $config; | ||||
private $pid; | private $pid; | ||||
private $daemonID; | private $daemonID; | ||||
private $deadline; | private $deadline; | ||||
private $heartbeat; | private $heartbeat; | ||||
private $stdoutBuffer; | private $stdoutBuffer; | ||||
private $restartAt; | private $restartAt; | ||||
private $silent; | |||||
private $shouldRestart = true; | private $shouldRestart = true; | ||||
private $shouldShutdown; | private $shouldShutdown; | ||||
private $future; | private $future; | ||||
private $traceMemory; | private $traceMemory; | ||||
public function __construct( | public function __construct( | ||||
PhutilDaemonOverseer $overseer, | PhutilDaemonOverseer $overseer, | ||||
$daemon_class, | $daemon_class, | ||||
Show All 22 Lines | final class PhutilDaemonHandle extends Phobject { | ||||
public function isDone() { | public function isDone() { | ||||
return (!$this->shouldRestart && !$this->isRunning()); | return (!$this->shouldRestart && !$this->isRunning()); | ||||
} | } | ||||
public function getFuture() { | public function getFuture() { | ||||
return $this->future; | return $this->future; | ||||
} | } | ||||
public function setSilent($silent) { | |||||
$this->silent = $silent; | |||||
return $this; | |||||
} | |||||
public function getSilent() { | |||||
return $this->silent; | |||||
} | |||||
public function setTraceMemory($trace_memory) { | public function setTraceMemory($trace_memory) { | ||||
$this->traceMemory = $trace_memory; | $this->traceMemory = $trace_memory; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getTraceMemory() { | public function getTraceMemory() { | ||||
return $this->traceMemory; | return $this->traceMemory; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 320 Lines • ▼ Show 20 Lines | if ($signame) { | ||||
$sigmsg = pht('Shutting down in response to signal %s.', $signo); | $sigmsg = pht('Shutting down in response to signal %s.', $signo); | ||||
} | } | ||||
$this->logMessage('EXIT', $sigmsg, $signo); | $this->logMessage('EXIT', $sigmsg, $signo); | ||||
$this->annihilateProcessGroup(); | $this->annihilateProcessGroup(); | ||||
} | } | ||||
private function logMessage($type, $message, $context = null) { | private function logMessage($type, $message, $context = null) { | ||||
if (!$this->getSilent()) { | $this->overseer->logMessage($type, $message, $context); | ||||
echo date('Y-m-d g:i:s A').' ['.$type.'] '.$message."\n"; | |||||
} | |||||
$this->dispatchEvent( | $this->dispatchEvent( | ||||
self::EVENT_DID_LOG, | self::EVENT_DID_LOG, | ||||
array( | array( | ||||
'type' => $type, | 'type' => $type, | ||||
'message' => $message, | 'message' => $message, | ||||
'context' => $context, | 'context' => $context, | ||||
)); | )); | ||||
} | } | ||||
public function didRemoveDaemon() { | public function didRemoveDaemon() { | ||||
$this->dispatchEvent(self::EVENT_WILL_EXIT); | $this->dispatchEvent(self::EVENT_WILL_EXIT); | ||||
} | } | ||||
} | } |