Page MenuHomePhabricator

Add a daemon overseer module to restart daemons when config changes
ClosedPublic

Authored by joshuaspence on Nov 10 2015, 8:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 25, 1:48 AM
Unknown Object (File)
Sat, Apr 20, 1:02 PM
Unknown Object (File)
Thu, Apr 18, 3:03 PM
Unknown Object (File)
Wed, Apr 17, 10:50 AM
Unknown Object (File)
Tue, Apr 16, 4:49 PM
Unknown Object (File)
Tue, Apr 16, 2:09 AM
Unknown Object (File)
Mon, Apr 15, 6:21 PM
Unknown Object (File)
Sat, Apr 13, 9:33 AM

Details

Summary

Fixes T7053. Depends on D14452.

Test Plan

Created a custom daemon which dumps out the config hash (by querying PhabricatorEnv::calculateEnvironmentHash()). Ran this daemon with ./bin/phd debug PhabricatorDebugDaemon and saw the config hash update within 30 seconds.

1<?php
2
3final class PhabricatorDebugDaemon extends PhabricatorDaemon {
4
5 protected function run() {
6 do {
7 PhabricatorCaches::destroyRequestCache();
8 echo PhabricatorEnv::calculateEnvironmentHash();
9
10 $this->sleep(1);
11 } while (!$this->shouldExit());
12 }
13
14}

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

joshuaspence retitled this revision from to Add a daemon overseer module to restart daemons when config changes.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
epriestley edited edge metadata.

I think we should a timer in this so it only queries if the last query was more than, say, 10 seconds ago. Looks good otherwise.

src/infrastructure/daemon/overseer/PhabricatorDaemonOverseerModule.php
39

Prefer new PhabricatorConfigEntryTransaction()->getTableName()

This revision now requires changes to proceed.Nov 10 2015, 8:19 PM
src/infrastructure/daemon/overseer/PhabricatorDaemonOverseerModule.php
16–19

Oh, we also shouldn't issue a restart immediately upon startup. If the current version hasn't been set yet, just load it without issuing a restart.

Ignore me, you already do that.

Although maybe it would be better not to do it as a side effect of construction, given that we're PhutilClassMapQuery'ing this thing. Running queries inside PhutilClassMapQuery feels a little iffy.

joshuaspence edited edge metadata.

Add timing check

Although maybe it would be better not to do it as a side effect of construction, given that we're PhutilClassMapQuery'ing this thing. Running queries inside PhutilClassMapQuery feels a little iffy.

Yeah agreed, I'll change it.

src/infrastructure/daemon/overseer/PhabricatorDaemonOverseerModule.php
16–19

We won't, that's why I query the version in the constructor.

joshuaspence edited edge metadata.

Less expensive constructor

src/infrastructure/daemon/overseer/PhabricatorDaemonOverseerModule.php
11–15

Prefer PhabricatorTime::getNow() so we can muck with it in unit tests if we ever need to.

32

Consider load over get to hint at the query.

43

I think this actually has an initialization problem? First time through we'll issue a reload?

45

We should always update the timestamp -- otherwise we'll query after 10s, then after 1s, 1s, 1s, 1s, ...

joshuaspence marked 7 inline comments as done.

As requested

This revision is now accepted and ready to land.Nov 10 2015, 9:42 PM