Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/daemon/management/PhabricatorDaemonManagementLaunchWorkflow.php
12256 views
1
<?php
2
3
final class PhabricatorDaemonManagementLaunchWorkflow
4
extends PhabricatorDaemonManagementWorkflow {
5
6
public function shouldParsePartial() {
7
return true;
8
}
9
10
protected function didConstruct() {
11
$this
12
->setName('launch')
13
->setExamples('**launch** [n] __daemon__ [options]')
14
->setSynopsis(pht(
15
'Start a specific __daemon__, or __n__ copies of a specific '.
16
'__daemon__.'))
17
->setArguments(
18
array(
19
array(
20
'name' => 'argv',
21
'wildcard' => true,
22
),
23
));
24
}
25
26
public function execute(PhutilArgumentParser $args) {
27
$argv = $args->getArg('argv');
28
29
$daemon_count = 1;
30
if ($argv) {
31
if (is_numeric(head($argv))) {
32
$daemon_count = array_shift($argv);
33
}
34
35
if ($daemon_count < 1) {
36
throw new PhutilArgumentUsageException(
37
pht('You must launch at least one daemon.'));
38
}
39
}
40
41
if (!$argv) {
42
throw new PhutilArgumentUsageException(
43
pht('You must specify which daemon to launch.'));
44
}
45
46
$daemon = array();
47
$daemon['class'] = array_shift($argv);
48
$daemon['label'] = $daemon['class'];
49
$daemon['argv'] = $argv;
50
51
$daemons = array_fill(0, $daemon_count, $daemon);
52
53
$this->launchDaemons($daemons, $is_debug = false);
54
55
return 0;
56
}
57
58
}
59
60