Reorganize PhutilDaemon into Overseers, Pools and Daemons in libphutil


Reorganize PhutilDaemon into Overseers, Pools and Daemons in libphutil

Ref T12298. Ultimate goal is to let daemon pools scale down to 0 daemons when they aren't doing anything. This doesn't do that yet (and attempts to change no behavior).

This reorganizes the daemon code to make this change easier. Currently, some daemons are in pools and some are not. Intead, make everything a pool (the Pull and Trigger daemons just get pools with maximum size 1).

New object hiearchy is:

  • Overseer
    • Pool
      • Daemon

...and those objects each pretty much take care of their own stuff, instead of having daemons reach up into the Overseer to dispatch events back to themselves.

Test Plan:

  • Ran phd debug, phd start, phd stop, phd status, etc.
  • Reviewed daemons in web console.
  • Changed config, saw daemons automatically restart.
  • Sent daemons signals.
  • Used --trace, activated memory tracing, activated verbose mode.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12298

Differential Revision: https://secure.phabricator.com/D17389

Event Timeline

CodeMouse92 added a subscriber: CodeMouse92.

Hey, the Chatbot is now refusing to start up since I pulled in the update with this commit. Here's the cursory stack trace:

[03-Mar-2017 16:36:06 America/Los_Angeles] [2017-03-03 16:36:06] EXCEPTION: (PhutilTypeMissingParametersException) Missing required parameters: label at [<phutil>/src/parser/PhutilTypeSpec.php:164]
[03-Mar-2017 16:36:06 America/Los_Angeles] arcanist(head=stable, ref.master=fe8ed2a6f8b0, ref.stable=822bc53ca306), phabricator(head=stable, ref.stable=216f6be11ece, custom=2), phutil(head=stable, ref.master=e509fc30ae78, ref.stable=76983f49b179)
[03-Mar-2017 16:36:06 America/Los_Angeles]   #0 PhutilTypeSpec::checkMap(array, array) called at [<phutil>/src/daemon/PhutilDaemonPool.php:31]
[03-Mar-2017 16:36:06 America/Los_Angeles]   #1 PhutilDaemonPool::newFromConfig(array) called at [<phutil>/src/daemon/PhutilDaemonOverseer.php:229]
[03-Mar-2017 16:36:06 America/Los_Angeles]   #2 PhutilDaemonOverseer::createDaemonPools() called at [<phutil>/src/daemon/PhutilDaemonOverseer.php:168]
[03-Mar-2017 16:36:06 America/Los_Angeles]   #3 PhutilDaemonOverseer::run() called at [<phabricator>/scripts/daemon/launch_daemon.php:24]

Not sure if I have enough info for a proper bug report. Your call?

This commit now has outstanding concerns.Mar 4 2017, 12:40 AM

If you'd like us to take a look, please file a bug report. Before doing so, make sure you have D17429.

This commit no longer requires audit.Mar 4 2017, 12:44 AM

Yep, D17429 fixes it! Awesome-sauce. That's exactly why I didn't file the bug report yet - I'm on stable, so I can be about a week behind.

All concerns with this commit have now been addressed.Mar 4 2017, 1:39 AM