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

Revert "Query daemons across all hosts with `./bin/phd status --all`."

This reverts commit 0ccebbe4b1ddd7b0e3e4b737e557570a3ced7dfa.

+39 -113
+13 -72
src/applications/daemon/management/PhabricatorDaemonManagementStatusWorkflow.php
··· 22 22 } 23 23 24 24 $status = 0; 25 - $table = id(new PhutilConsoleTable()) 26 - ->addColumns(array( 27 - 'pid' => array( 28 - 'title' => 'PID', 29 - ), 30 - 'started' => array( 31 - 'title' => 'Started', 32 - ), 33 - 'daemon' => array( 34 - 'title' => 'Daemon', 35 - ), 36 - 'argv' => array( 37 - 'title' => 'Arguments', 38 - ), 39 - )); 40 - 25 + printf( 26 + "%-5s\t%-24s\t%-50s%s\n", 27 + 'PID', 28 + 'Started', 29 + 'Daemon', 30 + 'Arguments'); 41 31 foreach ($daemons as $daemon) { 42 32 $name = $daemon->getName(); 43 33 if (!$daemon->isRunning()) { ··· 45 35 $status = 2; 46 36 $name = '<DEAD> '.$name; 47 37 } 48 - 49 - $table->addRow(array( 50 - 'pid' => $daemon->getPID(), 51 - 'started' => $daemon->getEpochStarted() 38 + printf( 39 + "%5s\t%-24s\t%-50s%s\n", 40 + $daemon->getPID(), 41 + $daemon->getEpochStarted() 52 42 ? date('M j Y, g:i:s A', $daemon->getEpochStarted()) 53 43 : null, 54 - 'daemon' => $name, 55 - 'argv' => csprintf('%LR', $daemon->getArgv()), 56 - )); 44 + $name, 45 + csprintf('%LR', $daemon->getArgv())); 57 46 } 58 47 59 - $table->draw(); 48 + return $status; 60 49 } 61 50 62 - protected function executeGlobal() { 63 - $console = PhutilConsole::getConsole(); 64 - $daemons = $this->loadAllRunningDaemons(); 65 - 66 - if (!$daemons) { 67 - $console->writeErr( 68 - "%s\n", 69 - pht('There are no running Phabricator daemons.')); 70 - return 1; 71 - } 72 - 73 - $status = 0; 74 - 75 - $table = id(new PhutilConsoleTable()) 76 - ->addColumns(array( 77 - 'id' => array( 78 - 'title' => 'ID', 79 - ), 80 - 'host' => array( 81 - 'title' => 'Host', 82 - ), 83 - 'pid' => array( 84 - 'title' => 'PID', 85 - ), 86 - 'started' => array( 87 - 'title' => 'Started', 88 - ), 89 - 'daemon' => array( 90 - 'title' => 'Daemon', 91 - ), 92 - 'argv' => array( 93 - 'title' => 'Arguments', 94 - ), 95 - )); 96 - 97 - foreach ($daemons as $daemon) { 98 - $table->addRow(array( 99 - 'id' => $daemon->getID(), 100 - 'host' => $daemon->getHost(), 101 - 'pid' => $daemon->getPID(), 102 - 'started' => date('M j Y, g:i:s A', $daemon->getDateCreated()), 103 - 'daemon' => $daemon->getDaemon(), 104 - 'argv' => csprintf('%LR', array() /* $daemon->getArgv() */), 105 - )); 106 - } 107 - 108 - $table->draw(); 109 - } 110 51 111 52 }
+21 -18
src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
··· 3 3 abstract class PhabricatorDaemonManagementWorkflow 4 4 extends PhabricatorManagementWorkflow { 5 5 6 - protected final function loadAvailableDaemonClasses() { 6 + protected function loadAvailableDaemonClasses() { 7 7 $loader = new PhutilSymbolLoader(); 8 8 return $loader 9 9 ->setAncestorClass('PhutilDaemon') ··· 11 11 ->selectSymbolsWithoutLoading(); 12 12 } 13 13 14 - protected final function getPIDDirectory() { 14 + public function getPIDDirectory() { 15 15 $path = PhabricatorEnv::getEnvConfig('phd.pid-directory'); 16 16 return $this->getControlDirectory($path); 17 17 } 18 18 19 - protected final function getLogDirectory() { 19 + public function getLogDirectory() { 20 20 $path = PhabricatorEnv::getEnvConfig('phd.log-directory'); 21 21 return $this->getControlDirectory($path); 22 22 } ··· 35 35 return $path; 36 36 } 37 37 38 - protected final function loadRunningDaemons() { 38 + public function loadRunningDaemons() { 39 39 $results = array(); 40 - $ids = array(); 41 40 42 41 $pid_dir = $this->getPIDDirectory(); 43 42 $pid_files = Filesystem::listDirectory($pid_dir); ··· 46 45 } 47 46 48 47 foreach ($pid_files as $pid_file) { 49 - $results[] = PhabricatorDaemonReference::newFromDictionary( 50 - $pid_dir.'/'.$pid_file); 51 - $ids[] = $ref->getDaemonLog()->getID(); 48 + $pid_data = Filesystem::readFile($pid_dir.'/'.$pid_file); 49 + $dict = json_decode($pid_data, true); 50 + if (!is_array($dict)) { 51 + // Just return a hanging reference, since control code needs to be 52 + // robust against unusual system states. 53 + $dict = array(); 54 + } 55 + $ref = PhabricatorDaemonReference::newFromDictionary($dict); 56 + $ref->setPIDFile($pid_dir.'/'.$pid_file); 57 + $results[] = $ref; 52 58 } 53 59 54 - $other = id(new PhabricatorDaemonLogQuery()) 55 - ->setViewer(PhabricatorUser::getOmnipotentUser()) 56 - ->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE) 57 - ->execute(); 58 - 59 - 60 + return $results; 60 61 } 61 62 62 63 private function findDaemonClass($substring) { ··· 92 93 return head($match); 93 94 } 94 95 95 - protected final function launchDaemon($class, array $argv, $debug) { 96 + 97 + protected function launchDaemon($class, array $argv, $debug) { 96 98 $daemon = $this->findDaemonClass($class); 97 99 $console = PhutilConsole::getConsole(); 98 100 ··· 210 212 } 211 213 } 212 214 213 - protected final function willLaunchDaemons() { 215 + protected function willLaunchDaemons() { 214 216 $console = PhutilConsole::getConsole(); 215 217 $console->writeErr(pht('Preparing to launch daemons.')."\n"); 216 218 ··· 222 224 /* -( Commands )----------------------------------------------------------- */ 223 225 224 226 225 - protected final function executeStartCommand($keep_leases = false) { 227 + protected function executeStartCommand($keep_leases = false) { 226 228 $console = PhutilConsole::getConsole(); 227 229 228 230 $running = $this->loadRunningDaemons(); ··· 276 278 return 0; 277 279 } 278 280 279 - protected final function executeStopCommand(array $pids) { 281 + 282 + protected function executeStopCommand(array $pids) { 280 283 $console = PhutilConsole::getConsole(); 281 284 282 285 $daemons = $this->loadRunningDaemons();
+5 -23
src/infrastructure/daemon/control/PhabricatorDaemonReference.php
··· 10 10 11 11 private $daemonLog; 12 12 13 - public static function newFromFile($path) { 14 - $pid_data = Filesystem::readFile($path); 15 - $dict = json_decode($pid_data, true); 16 - if (!is_array($dict)) { 17 - // Just return a hanging reference, since control code needs to be 18 - // robust against unusual system states. 19 - $dict = array(); 20 - } 21 - $ref = self::newFromDictionary($dict); 22 - $ref->pidFile = $path; 23 - return $ref; 24 - } 25 - 26 13 public static function newFromDictionary(array $dict) { 27 14 $ref = new PhabricatorDaemonReference(); 28 15 ··· 30 17 $ref->argv = idx($dict, 'argv', array()); 31 18 $ref->pid = idx($dict, 'pid'); 32 19 $ref->start = idx($dict, 'start'); 33 - 34 - $this->daemonLog = id(new PhabricatorDaemonLog())->loadOneWhere( 35 - 'daemon = %s AND pid = %d AND dateCreated = %d', 36 - $this->name, 37 - $this->pid, 38 - $this->start); 39 20 40 21 return $ref; 41 22 } ··· 85 66 return $this->start; 86 67 } 87 68 69 + public function setPIDFile($pid_file) { 70 + $this->pidFile = $pid_file; 71 + return $this; 72 + } 73 + 88 74 public function getPIDFile() { 89 75 return $this->pidFile; 90 - } 91 - 92 - public function getDaemonLog() { 93 - return $this->daemonLog; 94 76 } 95 77 96 78 public function isRunning() {