1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Start all daemons under a single overseer

Summary:
Ref T7352. This moves all the daemons under one overseer. The primary goal is to reduce the minimum footprint of an instance in the Phacility cluster, by reducing the number of processes each instance needs to run on daemon-tier hosts.

This improves scalability by roughly a factor of 2.

Test Plan:
  - Ran `phd debug`, `phd launch, `phd start`. Saw normal behavior, with only one total overseer.
  - Fataled dameons and saw the overseer restar them normally.
  - Used `phd status` and `phd stop` and got reasonable results (`phd status` is still a touch off).

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7352

Differential Revision: https://secure.phabricator.com/D11857
This commit is contained in:
epriestley 2015-02-22 13:45:23 -08:00
parent c2d66f29cd
commit f0f2b2cbeb
3 changed files with 53 additions and 60 deletions

View file

@ -39,9 +39,10 @@ final class PhabricatorDaemonManagementDebugWorkflow
}
$daemon_class = array_shift($argv);
return $this->launchDaemon(
$daemon_class,
$argv,
return $this->launchDaemons(
array(
array($daemon_class, $argv),
),
$is_debug = true,
$run_as_current_user);
}

View file

@ -43,13 +43,10 @@ final class PhabricatorDaemonManagementLaunchWorkflow
pht('You must specify which daemon to launch.'));
}
$daemon_class = array_shift($argv);
$daemon = array(array_shift($argv), $argv);
$daemons = array_fill(0, $daemon_count, $daemon);
$this->willLaunchDaemons();
for ($ii = 0; $ii < $daemon_count; $ii++) {
$this->launchDaemon($daemon_class, $argv, $is_debug = false);
}
$this->launchDaemons($daemons, $is_debug = false);
return 0;
}

View file

@ -105,13 +105,18 @@ abstract class PhabricatorDaemonManagementWorkflow
return head($match);
}
protected final function launchDaemon(
$class,
array $argv,
protected final function launchDaemons(
array $daemons,
$debug,
$run_as_current_user = false) {
$daemon = $this->findDaemonClass($class);
// Convert any shorthand classnames like "taskmaster" into proper class
// names.
foreach ($daemons as $key => $daemon) {
$class = $this->findDaemonClass($daemon[0]);
$daemons[$key][0] = $class;
}
$console = PhutilConsole::getConsole();
if (!$run_as_current_user) {
@ -136,34 +141,7 @@ abstract class PhabricatorDaemonManagementWorkflow
}
}
if ($debug) {
if ($argv) {
$console->writeOut(
pht(
"Launching daemon \"%s\" in debug mode (not daemonized) ".
"with arguments %s.\n",
$daemon,
csprintf('%LR', $argv)));
} else {
$console->writeOut(
pht(
"Launching daemon \"%s\" in debug mode (not daemonized).\n",
$daemon));
}
} else {
if ($argv) {
$console->writeOut(
pht(
"Launching daemon \"%s\" with arguments %s.\n",
$daemon,
csprintf('%LR', $argv)));
} else {
$console->writeOut(
pht(
"Launching daemon \"%s\".\n",
$daemon));
}
}
$this->printLaunchingDaemons($daemons, $debug);
$flags = array();
if ($debug || PhabricatorEnv::getEnvConfig('phd.trace')) {
@ -174,6 +152,12 @@ abstract class PhabricatorDaemonManagementWorkflow
$flags[] = '--verbose';
}
$instance = PhabricatorEnv::getEnvConfig('cluster.instance');
if ($instance) {
$flags[] = '-l';
$flags[] = $instance;
}
$config = array();
if (!$debug) {
@ -193,12 +177,14 @@ abstract class PhabricatorDaemonManagementWorkflow
$config['piddir'] = $pid_dir;
$config['daemons'] = array(
array(
'class' => $daemon,
$config['daemons'] = array();
foreach ($daemons as $daemon) {
list($class, $argv) = $daemon;
$config['daemons'][] = array(
'class' => $class,
'argv' => $argv,
),
);
);
}
$command = csprintf('./phd-daemon %Ls', $flags);
@ -304,14 +290,6 @@ abstract class PhabricatorDaemonManagementWorkflow
}
}
protected final function willLaunchDaemons() {
$console = PhutilConsole::getConsole();
$console->writeErr(pht('Preparing to launch daemons.')."\n");
$log_dir = $this->getLogDirectory().'/daemons.log';
$console->writeErr(pht("NOTE: Logs will appear in '%s'.", $log_dir)."\n\n");
}
/* -( Commands )----------------------------------------------------------- */
@ -359,12 +337,7 @@ abstract class PhabricatorDaemonManagementWorkflow
$daemons[] = array('PhabricatorTaskmasterDaemon', array());
}
$this->willLaunchDaemons();
foreach ($daemons as $spec) {
list($name, $argv) = $spec;
$this->launchDaemon($name, $argv, $is_debug = false);
}
$this->launchDaemons($daemons, $is_debug = false);
$console->writeErr(pht('Done.')."\n");
return 0;
@ -579,4 +552,26 @@ abstract class PhabricatorDaemonManagementWorkflow
return $conn_w->getAffectedRows();
}
private function printLaunchingDaemons(array $daemons, $debug) {
$console = PhutilConsole::getConsole();
if ($debug) {
$console->writeOut(pht('Launching daemons (in debug mode):'));
} else {
$console->writeOut(pht('Launching daemons:'));
}
$log_dir = $this->getLogDirectory().'/daemons.log';
$console->writeOut(
"\n%s\n\n",
pht('(Logs will appear in "%s".)', $log_dir));
foreach ($daemons as $daemon) {
list($class, $argv) = $daemon;
$console->writeOut(" %s %s\n", $class, implode(' ', $argv));
}
$console->writeOut("\n");
}
}