Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15450048
D14452.id34956.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D14452.id34956.diff
View Options
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
@@ -267,7 +267,7 @@
// groups that resist SIGTERM. Rather than trying to figure out if the
// 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 +370,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 +395,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,21 @@
$this->addDaemon($daemon, $config);
}
+ $i = 0;
+ $version = $this->getConfigVersion();
+
while (true) {
+ if (++$i % 30 == 0) {
+ $new_version = $this->getConfigVersion();
+
+ // If the configuration has changed, reload all daemons so that they
+ // pick up the new configuration.
+ if ($version != $new_version) {
+ $this->didReceiveReloadSignal(SIGHUP);
+ $version = $new_version;
+ }
+ }
+
$futures = array();
foreach ($this->getDaemonHandles() as $daemon) {
$daemon->update();
@@ -217,6 +231,24 @@
exit($this->err);
}
+ /**
+ * Calculate a version number for the current Phabricator configuration.
+ *
+ * The version number has no real meaning and does not provide any real
+ * indication of whether a configuration entry has been changed. The config
+ * version is intended to be a rough indicator that "something has changed",
+ * which indicates to the overseer that the daemons should be reloaded.
+ *
+ * @return int
+ */
+ private function getConfigVersion() {
+ $conn_r = id(new PhabricatorConfigEntry())->establishConnection('r');
+ return head(queryfx_one(
+ $conn_r,
+ 'SELECT MAX(id) FROM %T',
+ 'config_transaction'));
+ }
+
private function addDaemon(PhutilDaemonHandle $daemon, array $config) {
$id = $daemon->getDaemonID();
$this->daemons[$id] = array(
@@ -296,7 +328,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
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 29, 1:36 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7719579
Default Alt Text
D14452.id34956.diff (3 KB)
Attached To
Mode
D14452: Add daemon overseer modules to allow daemons to be externally reloaded
Attached
Detach File
Event Timeline
Log In to Comment