Page MenuHomePhabricator

D14452.id34940.diff
No OneTemporary

D14452.id34940.diff

diff --git a/src/daemon/PhutilDaemonHandle.php b/src/daemon/PhutilDaemonHandle.php
--- a/src/daemon/PhutilDaemonHandle.php
+++ b/src/daemon/PhutilDaemonHandle.php
@@ -257,7 +257,7 @@
// explicitly delineate PID/PGIDs from signals. We don't actually need it,
// so use the implicit "kill -TERM -pgid" form instead of the explicit
// "kill -TERM -- -pgid" form.
- exec("kill -TERM -{$pgid}");
+ posix_kill($pgid, SIGTERM);
sleep($this->getKillDelay());
// On OSX, we'll get a permission error on stderr if the SIGTERM was
@@ -268,6 +268,7 @@
// process group is still around or not, just SIGKILL unconditionally and
// ignore any error which may be raised.
exec("kill -KILL -{$pgid} 2>/dev/null");
+ posix_kill($pgid, SIGKILL);
$this->pid = null;
}
}
@@ -370,8 +371,7 @@
// naturally be restarted after it exits, as though it had exited after an
// unhandled exception.
- $pid = $this->pid;
- exec("kill -INT {$pid}");
+ posix_kill($this->pid, SIGINT);
}
public function didReceiveGracefulSignal($signo) {
@@ -396,8 +396,7 @@
$this->logMessage('DONE', $sigmsg, $signo);
- $pid = $this->pid;
- exec("kill -INT {$pid}");
+ posix_kill($this->pid, SIGINT);
}
public function didReceiveTerminalSignal($signo) {
diff --git a/src/daemon/PhutilDaemonOverseer.php b/src/daemon/PhutilDaemonOverseer.php
--- a/src/daemon/PhutilDaemonOverseer.php
+++ b/src/daemon/PhutilDaemonOverseer.php
@@ -184,7 +184,19 @@
$this->addDaemon($daemon, $config);
}
+ $i = 0;
+ $config_hash = $this->getConfigHash();
+
while (true) {
+ if (++$i % 10 == 0) {
+ $new_config_hash = $this->getConfigHash();
+
+ if ($config_hash != $new_config_hash) {
+ $this->didReceiveReloadSignal(SIGHUP);
+ $config_hash = $new_config_hash;
+ }
+ }
+
$futures = array();
foreach ($this->getDaemonHandles() as $daemon) {
$daemon->update();
@@ -217,6 +229,14 @@
exit($this->err);
}
+ private function getConfigHash() {
+ $config_entry = id(new PhabricatorConfigEntry())->loadOneWhere(
+ 'namespace = %s AND configKey = %s',
+ 'default',
+ 'config.hash');
+ return $config_entry->getValue();
+ }
+
private function addDaemon(PhutilDaemonHandle $daemon, array $config) {
$id = $daemon->getDaemonID();
$this->daemons[$id] = array(
@@ -296,7 +316,7 @@
if ((time() - $busy) < $scaleup_duration) {
// At least one daemon in the group was idle recently, so we have
- // not fullly
+ // not fully used all the available capacity.
$should_scale = false;
break;
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 22, 3:28 AM (3 d, 10 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7716352
Default Alt Text
D14452.id34940.diff (2 KB)

Event Timeline