Changeset View
Changeset View
Standalone View
Standalone View
src/daemon/PhutilDaemonHandle.php
Show First 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | if ($pid && $pgid) { | ||||
// groups that resist SIGTERM. Rather than trying to figure out if the | // groups that resist SIGTERM. Rather than trying to figure out if the | ||||
// process group is still around or not, just SIGKILL unconditionally and | // process group is still around or not, just SIGKILL unconditionally and | ||||
// ignore any error which may be raised. | // ignore any error which may be raised. | ||||
exec("kill -KILL -{$pgid} 2>/dev/null"); | exec("kill -KILL -{$pgid} 2>/dev/null"); | ||||
$this->pid = null; | $this->pid = null; | ||||
} | } | ||||
} | } | ||||
private function gracefulProcessGroup() { | |||||
$pid = $this->pid; | |||||
$pgid = posix_getpgid($pid); | |||||
if ($pid && $pgid) { | |||||
exec("kill -INT -{$pgid}"); | |||||
} | |||||
} | |||||
private function updateMemory() { | private function updateMemory() { | ||||
if ($this->traceMemory) { | if ($this->traceMemory) { | ||||
$memuse = number_format(memory_get_usage() / 1024, 1); | $memuse = number_format(memory_get_usage() / 1024, 1); | ||||
$this->logMessage('RAMS', 'Overseer Memory Usage: '.$memuse.' KB'); | $this->logMessage('RAMS', 'Overseer Memory Usage: '.$memuse.' KB'); | ||||
} | } | ||||
} | } | ||||
private function startDaemonProcess() { | private function startDaemonProcess() { | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | if ($signame) { | ||||
$signame); | $signame); | ||||
} else { | } else { | ||||
$sigmsg = pht( | $sigmsg = pht( | ||||
'Graceful shutdown in response to signal %d.', | 'Graceful shutdown in response to signal %d.', | ||||
$signo); | $signo); | ||||
} | } | ||||
$this->logMessage('DONE', $sigmsg, $signo); | $this->logMessage('DONE', $sigmsg, $signo); | ||||
$this->gracefulProcessGroup(); | |||||
$pid = $this->pid; | |||||
exec("kill -INT {$pid}"); | |||||
} | } | ||||
public function didReceiveTerminalSignal($signo) { | public function didReceiveTerminalSignal($signo) { | ||||
$signame = phutil_get_signal_name($signo); | $signame = phutil_get_signal_name($signo); | ||||
if ($signame) { | if ($signame) { | ||||
$sigmsg = "Shutting down in response to signal {$signo} ({$signame})."; | $sigmsg = "Shutting down in response to signal {$signo} ({$signame})."; | ||||
} else { | } else { | ||||
$sigmsg = "Shutting down in response to signal {$signo}."; | $sigmsg = "Shutting down in response to signal {$signo}."; | ||||
Show All 22 Lines |