Changeset View
Changeset View
Standalone View
Standalone View
src/daemon/PhutilDaemonPool.php
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | foreach ($this->getDaemons() as $daemon) { | ||||
$futures[] = $future; | $futures[] = $future; | ||||
} | } | ||||
} | } | ||||
return $futures; | return $futures; | ||||
} | } | ||||
public function didReceiveSignal($signal, $signo) { | public function didReceiveSignal($signal, $signo) { | ||||
switch ($signal) { | |||||
case PhutilDaemonOverseer::SIGNAL_GRACEFUL: | |||||
case PhutilDaemonOverseer::SIGNAL_TERMINATE: | |||||
$this->inShutdown = true; | |||||
break; | |||||
} | |||||
foreach ($this->getDaemons() as $daemon) { | foreach ($this->getDaemons() as $daemon) { | ||||
switch ($signal) { | switch ($signal) { | ||||
case PhutilDaemonOverseer::SIGNAL_NOTIFY: | case PhutilDaemonOverseer::SIGNAL_NOTIFY: | ||||
$daemon->didReceiveNotifySignal($signo); | $daemon->didReceiveNotifySignal($signo); | ||||
break; | break; | ||||
case PhutilDaemonOverseer::SIGNAL_RELOAD: | case PhutilDaemonOverseer::SIGNAL_RELOAD: | ||||
$daemon->didReceiveReloadSignal($signo); | $daemon->didReceiveReloadSignal($signo); | ||||
break; | break; | ||||
case PhutilDaemonOverseer::SIGNAL_GRACEFUL: | case PhutilDaemonOverseer::SIGNAL_GRACEFUL: | ||||
$this->inShutdown = true; | |||||
$daemon->didReceiveGracefulSignal($signo); | $daemon->didReceiveGracefulSignal($signo); | ||||
break; | break; | ||||
case PhutilDaemonOverseer::SIGNAL_TERMINATE: | case PhutilDaemonOverseer::SIGNAL_TERMINATE: | ||||
$this->inShutdown = true; | |||||
$daemon->didReceiveTerminateSignal($signo); | $daemon->didReceiveTerminateSignal($signo); | ||||
break; | break; | ||||
default: | default: | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Unknown signal "%s" ("%d").', | 'Unknown signal "%s" ("%d").', | ||||
$signal, | $signal, | ||||
$signo)); | $signo)); | ||||
Show All 35 Lines | public function updatePool() { | ||||
foreach ($daemons as $key => $daemon) { | foreach ($daemons as $key => $daemon) { | ||||
$daemon->update(); | $daemon->update(); | ||||
if ($daemon->isDone()) { | if ($daemon->isDone()) { | ||||
$daemon->didExit(); | $daemon->didExit(); | ||||
unset($this->daemons[$key]); | unset($this->daemons[$key]); | ||||
if ($this->shouldShutdown()) { | |||||
$this->logMessage( | |||||
'DOWN', | |||||
pht( | |||||
'Pool "%s" is exiting, with %s daemon(s) remaining.', | |||||
$this->getPoolLabel(), | |||||
new PhutilNumber(count($this->daemons)))); | |||||
} else { | |||||
$this->logMessage( | $this->logMessage( | ||||
'POOL', | 'POOL', | ||||
pht( | pht( | ||||
'Autoscale pool "%s" scaled down to %s daemon(s).', | 'Autoscale pool "%s" scaled down to %s daemon(s).', | ||||
$this->getPoolLabel(), | $this->getPoolLabel(), | ||||
new PhutilNumber(count($this->daemons)))); | new PhutilNumber(count($this->daemons)))); | ||||
} | } | ||||
} | } | ||||
} | |||||
$this->updateAutoscale(); | $this->updateAutoscale(); | ||||
} | } | ||||
public function isHibernating() { | public function isHibernating() { | ||||
foreach ($this->getDaemons() as $daemon) { | foreach ($this->getDaemons() as $daemon) { | ||||
if (!$daemon->isHibernating()) { | if (!$daemon->isHibernating()) { | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines |