mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 08:12:40 +01:00
d89b8ce2b2
Summary: Ref T1670. Mostly, use PhutilArgumentParser. This breaks up the mismash of functional stuff and PhabriatorDaemonControl into proper argumentparser Workflows. There are no functional changes, except that I removed the "pingConduit()" call prior to starting daemons, because I intend to remove all Conduit integration. Test Plan: - Ran `phd list`. - Ran `phd status` (running daemons). - Ran `phd status` (no running daemons). - Ran `phd stop <pid>` (dead task). - Ran `phd stop <pid>` (live task). - Ran `phd stop zebra` (invalid PID). - Ran `phd stop 1` (bad PID). - Ran `phd stop`. - Ran `phd debug zebra` (no match). - Ran `phd debug e` (ambiguous). - Ran `phd debug task`. - Ran `phd launch task`. - Ran `phd launch 0 task` (invalid arg). - Ran `phd launch 2 task`. - Ran `phd help`. - Ran `phd help list`. - Ran `phd start`. - Ran `phd restart`. - Looked at Repositories (daemon running). - Looked at Repositories (daemon not running). Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1670 Differential Revision: https://secure.phabricator.com/D6490
54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
<?php
|
|
|
|
final class PhabricatorDaemonManagementLaunchWorkflow
|
|
extends PhabricatorDaemonManagementWorkflow {
|
|
|
|
public function shouldParsePartial() {
|
|
return true;
|
|
}
|
|
|
|
public function didConstruct() {
|
|
$this
|
|
->setName('launch')
|
|
->setSynopsis(pht('Show a list of available daemons.'))
|
|
->setArguments(
|
|
array(
|
|
array(
|
|
'name' => 'argv',
|
|
'wildcard' => true,
|
|
),
|
|
));
|
|
}
|
|
|
|
public function execute(PhutilArgumentParser $args) {
|
|
$argv = $args->getArg('argv');
|
|
|
|
$daemon_count = 1;
|
|
if ($argv) {
|
|
if (is_numeric(head($argv))) {
|
|
$daemon_count = array_shift($argv);
|
|
}
|
|
|
|
if ($daemon_count < 1) {
|
|
throw new PhutilArgumentUsageException(
|
|
pht('You must launch at least one daemon.'));
|
|
}
|
|
}
|
|
|
|
if (!$argv) {
|
|
throw new PhutilArgumentUsageException(
|
|
pht('You must specify which daemon to launch.'));
|
|
}
|
|
|
|
$daemon_class = array_shift($argv);
|
|
|
|
$this->willLaunchDaemons();
|
|
|
|
for ($ii = 0; $ii < $daemon_count; $ii++) {
|
|
$this->launchDaemon($daemon_class, $argv, $is_debug = false);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
}
|