@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+53 -60
+4 -3
src/applications/daemon/management/PhabricatorDaemonManagementDebugWorkflow.php
··· 39 39 } 40 40 41 41 $daemon_class = array_shift($argv); 42 - return $this->launchDaemon( 43 - $daemon_class, 44 - $argv, 42 + return $this->launchDaemons( 43 + array( 44 + array($daemon_class, $argv), 45 + ), 45 46 $is_debug = true, 46 47 $run_as_current_user); 47 48 }
+3 -6
src/applications/daemon/management/PhabricatorDaemonManagementLaunchWorkflow.php
··· 43 43 pht('You must specify which daemon to launch.')); 44 44 } 45 45 46 - $daemon_class = array_shift($argv); 46 + $daemon = array(array_shift($argv), $argv); 47 + $daemons = array_fill(0, $daemon_count, $daemon); 47 48 48 - $this->willLaunchDaemons(); 49 - 50 - for ($ii = 0; $ii < $daemon_count; $ii++) { 51 - $this->launchDaemon($daemon_class, $argv, $is_debug = false); 52 - } 49 + $this->launchDaemons($daemons, $is_debug = false); 53 50 54 51 return 0; 55 52 }
+46 -51
src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
··· 105 105 return head($match); 106 106 } 107 107 108 - protected final function launchDaemon( 109 - $class, 110 - array $argv, 108 + protected final function launchDaemons( 109 + array $daemons, 111 110 $debug, 112 111 $run_as_current_user = false) { 113 112 114 - $daemon = $this->findDaemonClass($class); 113 + // Convert any shorthand classnames like "taskmaster" into proper class 114 + // names. 115 + foreach ($daemons as $key => $daemon) { 116 + $class = $this->findDaemonClass($daemon[0]); 117 + $daemons[$key][0] = $class; 118 + } 119 + 115 120 $console = PhutilConsole::getConsole(); 116 121 117 122 if (!$run_as_current_user) { ··· 136 141 } 137 142 } 138 143 139 - if ($debug) { 140 - if ($argv) { 141 - $console->writeOut( 142 - pht( 143 - "Launching daemon \"%s\" in debug mode (not daemonized) ". 144 - "with arguments %s.\n", 145 - $daemon, 146 - csprintf('%LR', $argv))); 147 - } else { 148 - $console->writeOut( 149 - pht( 150 - "Launching daemon \"%s\" in debug mode (not daemonized).\n", 151 - $daemon)); 152 - } 153 - } else { 154 - if ($argv) { 155 - $console->writeOut( 156 - pht( 157 - "Launching daemon \"%s\" with arguments %s.\n", 158 - $daemon, 159 - csprintf('%LR', $argv))); 160 - } else { 161 - $console->writeOut( 162 - pht( 163 - "Launching daemon \"%s\".\n", 164 - $daemon)); 165 - } 166 - } 144 + $this->printLaunchingDaemons($daemons, $debug); 167 145 168 146 $flags = array(); 169 147 if ($debug || PhabricatorEnv::getEnvConfig('phd.trace')) { ··· 172 150 173 151 if ($debug || PhabricatorEnv::getEnvConfig('phd.verbose')) { 174 152 $flags[] = '--verbose'; 153 + } 154 + 155 + $instance = PhabricatorEnv::getEnvConfig('cluster.instance'); 156 + if ($instance) { 157 + $flags[] = '-l'; 158 + $flags[] = $instance; 175 159 } 176 160 177 161 $config = array(); ··· 193 177 194 178 $config['piddir'] = $pid_dir; 195 179 196 - $config['daemons'] = array( 197 - array( 198 - 'class' => $daemon, 180 + $config['daemons'] = array(); 181 + foreach ($daemons as $daemon) { 182 + list($class, $argv) = $daemon; 183 + $config['daemons'][] = array( 184 + 'class' => $class, 199 185 'argv' => $argv, 200 - ), 201 - ); 186 + ); 187 + } 202 188 203 189 $command = csprintf('./phd-daemon %Ls', $flags); 204 190 ··· 304 290 } 305 291 } 306 292 307 - protected final function willLaunchDaemons() { 308 - $console = PhutilConsole::getConsole(); 309 - $console->writeErr(pht('Preparing to launch daemons.')."\n"); 310 - 311 - $log_dir = $this->getLogDirectory().'/daemons.log'; 312 - $console->writeErr(pht("NOTE: Logs will appear in '%s'.", $log_dir)."\n\n"); 313 - } 314 - 315 293 316 294 /* -( Commands )----------------------------------------------------------- */ 317 295 ··· 359 337 $daemons[] = array('PhabricatorTaskmasterDaemon', array()); 360 338 } 361 339 362 - $this->willLaunchDaemons(); 363 - 364 - foreach ($daemons as $spec) { 365 - list($name, $argv) = $spec; 366 - $this->launchDaemon($name, $argv, $is_debug = false); 367 - } 340 + $this->launchDaemons($daemons, $is_debug = false); 368 341 369 342 $console->writeErr(pht('Done.')."\n"); 370 343 return 0; ··· 577 550 WHERE leaseExpires > UNIX_TIMESTAMP()', 578 551 $task_table->getTableName()); 579 552 return $conn_w->getAffectedRows(); 553 + } 554 + 555 + 556 + private function printLaunchingDaemons(array $daemons, $debug) { 557 + $console = PhutilConsole::getConsole(); 558 + 559 + if ($debug) { 560 + $console->writeOut(pht('Launching daemons (in debug mode):')); 561 + } else { 562 + $console->writeOut(pht('Launching daemons:')); 563 + } 564 + 565 + $log_dir = $this->getLogDirectory().'/daemons.log'; 566 + $console->writeOut( 567 + "\n%s\n\n", 568 + pht('(Logs will appear in "%s".)', $log_dir)); 569 + 570 + foreach ($daemons as $daemon) { 571 + list($class, $argv) = $daemon; 572 + $console->writeOut(" %s %s\n", $class, implode(' ', $argv)); 573 + } 574 + $console->writeOut("\n"); 580 575 } 581 576 582 577 }