Page MenuHomePhabricator

Add configuration to specify additional daemons on `phd start`.
AbandonedPublic

Authored by joshuaspence on May 18 2014, 3:47 AM.
Tags
None
Referenced Files
F13083318: D9176.diff
Wed, Apr 24, 10:30 PM
Unknown Object (File)
Thu, Apr 11, 9:06 AM
Unknown Object (File)
Sun, Apr 7, 7:12 AM
Unknown Object (File)
Fri, Apr 5, 4:18 PM
Unknown Object (File)
Wed, Apr 3, 1:11 PM
Unknown Object (File)
Sun, Mar 31, 7:13 AM
Unknown Object (File)
Wed, Mar 27, 5:50 PM
Unknown Object (File)
Jan 19 2024, 9:39 PM
Subscribers

Details

Summary

Fixes T3145. Currently, the only configuration that can be used to customize daemons that are launched with phd start is phd.start-taskmasters, which controls the number of PhabricatorTaskmasterDaemon daemons which are spawned. The only way to launch additional daemons (besides PhabricatorTaskmasterDaemon daemons) is with phd launch.

Replacing phd.start-taskmasters with phd.start-daemons allows full control over exactly which daemons are launched with phd start. This greatly simplifies the management of phd daemons.

Test Plan

Added the following to conf/custom/myconfig.conf.php:

<?php

return array(
  // ...
  'phd.start-daemons' => array(
    'PhabricatorTaskmasterDaemon' => 8,
    'PhabricatorRepositoryPullLocalDaemon' => array(
      array(),
      array('X', '--not', 'Y'),
    ),
    'PhabricatorGarbageCollectorDaemon' => 1,
    'PhabricatorFactDaemon' => 1,
  ),
  // ...
);

Ran ./bin/phd restart and ensured that the requested daemons were started:

> sudo ./bin/phd start
Preparing to launch daemons.
NOTE: Logs will appear in '/mnt/logs/phd/daemons.log'.

Launching daemon "PhabricatorTaskmasterDaemon".
Launching daemon "PhabricatorTaskmasterDaemon".
Launching daemon "PhabricatorTaskmasterDaemon".
Launching daemon "PhabricatorTaskmasterDaemon".
Launching daemon "PhabricatorTaskmasterDaemon".
Launching daemon "PhabricatorTaskmasterDaemon".
Launching daemon "PhabricatorTaskmasterDaemon".
Launching daemon "PhabricatorTaskmasterDaemon".
Launching daemon "PhabricatorRepositoryPullLocalDaemon".
Launching daemon "PhabricatorRepositoryPullLocalDaemon".
Launching daemon "PhabricatorGarbageCollectorDaemon".
Launching daemon "PhabricatorFactDaemon".
Done.

Diff Detail

Repository
rP Phabricator
Branch
phd-config
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 814
Build 814: [Placeholder Plan] Wait for 30 Seconds

Event Timeline

joshuaspence retitled this revision from to Add configuration to specify additional daemons on `phd start`..
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
joshuaspence edited edge metadata.

Fixing a minor issue.

joshuaspence added inline comments.
src/applications/config/option/PhabricatorPHDConfigOptions.php
24–30

We may want to retain this configuration option and, maybe, deprecate it.

src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
263

Probably should use PhutilTypeSpec here.

Lock the phd.start-daemons configuration option so that it cannot be modified from the web interface.

Use PhutilTypeSpec for checking configuration type.

epriestley edited edge metadata.

Hmm, let's structure this like this, instead?

array(
  array(
    'daemon' => 'PhabricatorRepositoryPullLocalDaemon',
    'arguments' => array('x', 'y'),
    'copies' => 8,
  ),
  ...
)

Right now, there's no room to add keys we might want to add in the future, like nice (T4804), user (switch permissions to a user), debug (verbose mode for just one daemon?), env (set environment?), cwd, you can't start several copies of a daemon with arguments, etc. We'll probably only ever implement 1 or 2 of these, but they seem like reasonable things this might want to provide some day.

Beyond that, one major downside to this approach is that installs which adjust the configuration slightly (to launch more or fewer taskmasters) will no longer receive updates to the default configuration: if we add "FactCursorDaemon" in the upstream next week, any installs which have adjusted the taskmaster count will completely override the new default configuration with their adjustments.

Offhand, I don't have a great solution to this, but it seems like a significant problem. One possibility is that we could implement merge rules for the configuration, and read all the configuration levels, overwriting key-by-key at each level. This would survive the addition of new daemons, but not adjustments to default arguments.

This revision now requires changes to proceed.May 19 2014, 3:07 PM

Beyond that, one major downside to this approach is that installs which adjust the configuration slightly (to launch more or fewer taskmasters) will no longer receive updates to the default configuration: if we add "FactCursorDaemon" in the upstream next week, any installs which have adjusted the taskmaster count will completely override the new default configuration with their adjustments.

I had a few ideas about this. Some possibilities:

  1. Retain the phd.start-taskmasters configuration and allow phd.start-daemons to be null (specifying that the user wants the default configuration). When using the default configuration, we read from phd.start-taskmasters in order to determine the number of PhabricatorTaskmasterDaemons to be run.
  2. Provide two separate configuration options, phd.start-daemons and phd.start-additional-daemons. The form can be used to override the default daemons whilst the latter is used to specify additional daemons to be launched with the defaults.
joshuaspence edited edge metadata.

Change the PhutilTypeSpec that is used to list phd start daemons.

joshuaspence edited edge metadata.

Whoops. Fixing my mistakes.

This isn't really the direction in which we want to head (in particular, see T4209).