@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.

Support autoscaling daemons in phd

Summary: Ref T7352. This supports passing autoscaling configuration to daemons, and adds `debug --autoscale`.

Test Plan: See D11711.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7352

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

+50 -20
+16 -2
src/applications/daemon/management/PhabricatorDaemonManagementDebugWorkflow.php
··· 26 26 'help' => 'Run the daemon as the current user '. 27 27 'instead of the configured phd.user', 28 28 ), 29 + array( 30 + 'name' => 'autoscale', 31 + 'help' => pht('Put the daemon in an autoscale group.'), 32 + ), 29 33 )); 30 34 } 31 35 ··· 38 42 pht('You must specify which daemon to debug.')); 39 43 } 40 44 41 - $daemon_class = array_shift($argv); 45 + $config = array(); 46 + 47 + $config['class'] = array_shift($argv); 48 + $config['argv'] = $argv; 49 + 50 + if ($args->getArg('autoscale')) { 51 + $config['autoscale'] = array( 52 + 'group' => 'debug', 53 + ); 54 + } 55 + 42 56 return $this->launchDaemons( 43 57 array( 44 - array($daemon_class, $argv), 58 + $config, 45 59 ), 46 60 $is_debug = true, 47 61 $run_as_current_user);
+4 -1
src/applications/daemon/management/PhabricatorDaemonManagementLaunchWorkflow.php
··· 43 43 pht('You must specify which daemon to launch.')); 44 44 } 45 45 46 - $daemon = array(array_shift($argv), $argv); 46 + $daemon = array(); 47 + $daemon['class'] = array_shift($argv); 48 + $daemon['argv'] = $argv; 49 + 47 50 $daemons = array_fill(0, $daemon_count, $daemon); 48 51 49 52 $this->launchDaemons($daemons, $is_debug = false);
+27 -17
src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
··· 113 113 // Convert any shorthand classnames like "taskmaster" into proper class 114 114 // names. 115 115 foreach ($daemons as $key => $daemon) { 116 - $class = $this->findDaemonClass($daemon[0]); 117 - $daemons[$key][0] = $class; 116 + $class = $this->findDaemonClass($daemon['class']); 117 + $daemons[$key]['class'] = $class; 118 118 } 119 119 120 120 $console = PhutilConsole::getConsole(); ··· 176 176 Filesystem::assertWritable($pid_dir); 177 177 178 178 $config['piddir'] = $pid_dir; 179 - 180 - $config['daemons'] = array(); 181 - foreach ($daemons as $daemon) { 182 - list($class, $argv) = $daemon; 183 - $config['daemons'][] = array( 184 - 'class' => $class, 185 - 'argv' => $argv, 186 - ); 187 - } 179 + $config['daemons'] = $daemons; 188 180 189 181 $command = csprintf('./phd-daemon %Ls', $flags); 190 182 ··· 327 319 } 328 320 329 321 $daemons = array( 330 - array('PhabricatorRepositoryPullLocalDaemon', array()), 331 - array('PhabricatorGarbageCollectorDaemon', array()), 332 - array('PhabricatorTriggerDaemon', array()), 322 + array( 323 + 'class' => 'PhabricatorRepositoryPullLocalDaemon', 324 + ), 325 + array( 326 + 'class' => 'PhabricatorGarbageCollectorDaemon', 327 + ), 328 + array( 329 + 'class' => 'PhabricatorTriggerDaemon', 330 + ), 333 331 ); 334 332 335 333 $taskmasters = PhabricatorEnv::getEnvConfig('phd.start-taskmasters'); 336 334 for ($ii = 0; $ii < $taskmasters; $ii++) { 337 - $daemons[] = array('PhabricatorTaskmasterDaemon', array()); 335 + $daemons[] = array( 336 + 'class' => 'PhabricatorTaskmasterDaemon', 337 + ); 338 338 } 339 339 340 340 $this->launchDaemons($daemons, $is_debug = false); ··· 568 568 pht('(Logs will appear in "%s".)', $log_dir)); 569 569 570 570 foreach ($daemons as $daemon) { 571 - list($class, $argv) = $daemon; 572 - $console->writeOut(" %s %s\n", $class, implode(' ', $argv)); 571 + $is_autoscale = isset($daemon['autoscale']['group']); 572 + if ($is_autoscale) { 573 + $autoscale = pht('(Autoscaling)'); 574 + } else { 575 + $autoscale = pht('(Static)'); 576 + } 577 + 578 + $console->writeOut( 579 + " %s %s\n", 580 + $daemon['class'], 581 + $autoscale, 582 + implode(' ', idx($daemon, 'argv', array()))); 573 583 } 574 584 $console->writeOut("\n"); 575 585 }
+3
src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php
··· 12 12 ->execute(); 13 13 14 14 if ($tasks) { 15 + $this->willBeginWork(); 16 + 15 17 foreach ($tasks as $task) { 16 18 $id = $task->getID(); 17 19 $class = $task->getTaskClass(); ··· 55 57 56 58 // The first time we sleep, we add a random offset to try to spread 57 59 // the sleep times out somewhat evenly. 60 + $this->willBeginIdle(); 58 61 $sleep = $taskmaster_count + $offset; 59 62 $offset = 0; 60 63 }