Hoa central
Start.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Worker\Bin;
38 
39 use Hoa\Console;
40 use Hoa\Worker;
41 
51 {
57  protected $options = [
58  ['fastcgi', Console\GetOption::REQUIRED_ARGUMENT, 'f'],
59  ['help', Console\GetOption::NO_ARGUMENT, 'h'],
60  ['help', Console\GetOption::NO_ARGUMENT, '?']
61  ];
62 
63 
64 
70  public function main()
71  {
72  $fastcgi = '127.0.0.1:9000';
73 
74  while (false !== $c = $this->getOption($v)) {
75  switch ($c) {
76  case 'f':
77  $fastcgi = $v;
78 
79  break;
80 
81  case 'h':
82  case '?':
83  return $this->usage();
84 
85  case '__ambiguous':
86  $this->resolveOptionAmbiguity($v);
87 
88  break;
89  }
90  }
91 
92  $this->parser->listInputs($workerPath);
93 
94  if (null === $workerPath) {
95  return $this->usage();
96  }
97 
99  'tcp://' . $fastcgi,
100  $workerPath
101  );
102 
103  echo $output, "\n";
104 
105  return;
106  }
107 
113  public function usage()
114  {
115  echo
116  'Usage : worker:start <options> <worker_path>', "\n",
117  'Options :', "\n",
118  $this->makeUsageOptionsList([
119  'f' => 'PHP-FPM socket URI (default: 127.0.0.1:9000).',
120  'help' => 'This help.'
121  ]), "\n";
122 
123  return;
124  }
125 }
126 
127 __halt_compiler();
128 Start a worker.
makeUsageOptionsList(Array $definitions=[])
Definition: Kit.php:149
getOption(&$optionValue, $short=null)
Definition: Kit.php:104
resolveOptionAmbiguity(Array $solutions)
Definition: Kit.php:190
static start($socket, $workerPath, Array $fastcgiParameters=[])
Definition: Shared.php:295