Hoa central
Stop.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Worker\Bin;
38 
39 use Hoa\Console;
40 use Hoa\Core;
41 use Hoa\Worker;
42 
52 {
58  protected $options = [
60  ['help', Console\GetOption::NO_ARGUMENT, 'h'],
61  ['help', Console\GetOption::NO_ARGUMENT, '?']
62  ];
63 
64 
65 
71  public function main()
72  {
73  $run = 'hoa://Data/Variable/Run';
74 
75  while (false !== $c = $this->getOption($v)) {
76  switch ($c) {
77  case 'r':
78  $run = $v;
79 
80  break;
81 
82  case 'h':
83  case '?':
84  return $this->usage();
85 
86  case '__ambiguous':
87  $this->resolveOptionAmbiguity($v);
88 
89  break;
90  }
91  }
92 
93  $this->parser->listInputs($workerId);
94 
95  if (null === $workerId) {
96  return $this->usage();
97  }
98 
99 
100  $run = resolve($run);
101  Core::getInstance()->initialize([
102  'protocol.Data/Variable/Run' => "\r" . $run . DS
103  ]);
104  $password = $this->readPassword('Password: ');
105  $sw = new Worker\Backend\Shared($workerId, $password);
106  $sw->stop();
107 
108  return;
109  }
110 
116  public function usage()
117  {
118  echo
119  'Usage : worker:stop <options> <worker_id>', "\n",
120  'Options :', "\n",
121  $this->makeUsageOptionsList([
122  'run' => 'Define hoa://Data/Variable/Run/ path.',
123  'help' => 'This help.'
124  ]), "\n";
125 
126  return;
127  }
128 }
129 
130 __halt_compiler();
131 Stop a worker.
makeUsageOptionsList(Array $definitions=[])
Definition: Kit.php:149
readPassword($prefix=null)
Definition: Kit.php:260
static getInstance()
Definition: Core.php:193
getOption(&$optionValue, $short=null)
Definition: Kit.php:104
resolveOptionAmbiguity(Array $solutions)
Definition: Kit.php:190