Page MenuHomePhabricator

D17560.diff
No OneTemporary

D17560.diff

diff --git a/src/daemon/PhutilDaemon.php b/src/daemon/PhutilDaemon.php
--- a/src/daemon/PhutilDaemon.php
+++ b/src/daemon/PhutilDaemon.php
@@ -139,7 +139,7 @@
}
// Don't hibernate for too long.
- $duration = max($duration, phutil_units('3 minutes in seconds'));
+ $duration = min($duration, phutil_units('3 minutes in seconds'));
$this->emitOverseerMessage(
self::MESSAGETYPE_HIBERNATE,
diff --git a/src/daemon/PhutilDaemonOverseer.php b/src/daemon/PhutilDaemonOverseer.php
--- a/src/daemon/PhutilDaemonOverseer.php
+++ b/src/daemon/PhutilDaemonOverseer.php
@@ -184,6 +184,8 @@
}
$futures = array();
+
+ $running_pools = false;
foreach ($this->getDaemonPools() as $pool) {
$pool->updatePool();
@@ -198,6 +200,10 @@
foreach ($pool->getFutures() as $future) {
$futures[] = $future;
}
+
+ if ($pool->getDaemons()) {
+ $running_pools = true;
+ }
}
$this->updatePidfile();
@@ -205,7 +211,7 @@
$this->waitForDaemonFutures($futures);
- if (!$futures) {
+ if (!$futures && !$running_pools) {
if ($this->shouldShutdown()) {
break;
}
diff --git a/src/daemon/PhutilDaemonPool.php b/src/daemon/PhutilDaemonPool.php
--- a/src/daemon/PhutilDaemonPool.php
+++ b/src/daemon/PhutilDaemonPool.php
@@ -124,6 +124,13 @@
}
public function didReceiveSignal($signal, $signo) {
+ switch ($signal) {
+ case PhutilDaemonOverseer::SIGNAL_GRACEFUL:
+ case PhutilDaemonOverseer::SIGNAL_TERMINATE:
+ $this->inShutdown = true;
+ break;
+ }
+
foreach ($this->getDaemons() as $daemon) {
switch ($signal) {
case PhutilDaemonOverseer::SIGNAL_NOTIFY:
@@ -133,11 +140,9 @@
$daemon->didReceiveReloadSignal($signo);
break;
case PhutilDaemonOverseer::SIGNAL_GRACEFUL:
- $this->inShutdown = true;
$daemon->didReceiveGracefulSignal($signo);
break;
case PhutilDaemonOverseer::SIGNAL_TERMINATE:
- $this->inShutdown = true;
$daemon->didReceiveTerminateSignal($signo);
break;
default:
@@ -189,12 +194,21 @@
unset($this->daemons[$key]);
- $this->logMessage(
- 'POOL',
- pht(
- 'Autoscale pool "%s" scaled down to %s daemon(s).',
- $this->getPoolLabel(),
- new PhutilNumber(count($this->daemons))));
+ 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(
+ 'POOL',
+ pht(
+ 'Autoscale pool "%s" scaled down to %s daemon(s).',
+ $this->getPoolLabel(),
+ new PhutilNumber(count($this->daemons))));
+ }
}
}

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 10, 10:17 PM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8756274
Default Alt Text
D17560.diff (2 KB)

Event Timeline