2013-07-19 00:28:56 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorDaemonManagementLaunchWorkflow
|
|
|
|
extends PhabricatorDaemonManagementWorkflow {
|
|
|
|
|
|
|
|
public function shouldParsePartial() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-15 21:42:07 +01:00
|
|
|
protected function didConstruct() {
|
2013-07-19 00:28:56 +02:00
|
|
|
$this
|
|
|
|
->setName('launch')
|
2013-08-06 18:10:53 +02:00
|
|
|
->setExamples('**launch** [n] __daemon__ [options]')
|
|
|
|
->setSynopsis(pht(
|
|
|
|
'Start a specific __daemon__, or __n__ copies of a specific '.
|
|
|
|
'__daemon__.'))
|
2013-07-19 00:28:56 +02:00
|
|
|
->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.'));
|
|
|
|
}
|
|
|
|
|
2015-02-23 01:07:16 +01:00
|
|
|
$daemon = array();
|
|
|
|
$daemon['class'] = array_shift($argv);
|
|
|
|
$daemon['argv'] = $argv;
|
|
|
|
|
2015-02-22 22:45:23 +01:00
|
|
|
$daemons = array_fill(0, $daemon_count, $daemon);
|
2013-07-19 00:28:56 +02:00
|
|
|
|
2015-02-22 22:45:23 +01:00
|
|
|
$this->launchDaemons($daemons, $is_debug = false);
|
2013-07-19 00:28:56 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|