diff --git a/src/daemon/PhutilDaemonHandle.php b/src/daemon/PhutilDaemonHandle.php --- a/src/daemon/PhutilDaemonHandle.php +++ b/src/daemon/PhutilDaemonHandle.php @@ -24,6 +24,7 @@ private $shouldRestart = true; private $shouldShutdown; private $hibernating = false; + private $shouldSendExitEvent = false; private function __construct() { // @@ -90,6 +91,7 @@ public function didLaunch() { $this->restartAt = time(); + $this->shouldSendExitEvent = true; $this->dispatchEvent( self::EVENT_DID_LAUNCH, @@ -184,7 +186,6 @@ if ($this->shouldShutdown) { $this->restartAt = null; - $this->dispatchEvent(self::EVENT_WILL_EXIT); } else { $this->scheduleRestart(); } @@ -500,5 +501,13 @@ ); } + public function didExit() { + if ($this->shouldSendExitEvent) { + $this->dispatchEvent(self::EVENT_WILL_EXIT); + $this->shouldSendExitEvent = false; + } + + return $this; + } } diff --git a/src/daemon/PhutilDaemonPool.php b/src/daemon/PhutilDaemonPool.php --- a/src/daemon/PhutilDaemonPool.php +++ b/src/daemon/PhutilDaemonPool.php @@ -185,6 +185,8 @@ $daemon->update(); if ($daemon->isDone()) { + $daemon->didExit(); + unset($this->daemons[$key]); $this->logMessage(