Beispiel #1
0
 /** {@inheritdoc} */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->parseCommandLine($input, $alsoDisable, $includeRemote, $factory, $signal);
     $registry = $this->getRegistry();
     foreach ($registry->getSharedWorkerNames() as $name) {
         $address = $registry->getSharedWorkerSocketAddress($name);
         $local = IdentificationHelper::isLocalAddress($address);
         if (!$includeRemote & !$local) {
             $output->writeln('Skipped remote worker <comment>' . $name . '</comment>.');
             continue;
         }
         $wFactory = $registry->getSharedWorkerFactoryName($name);
         if ($factory !== null && $wFactory != $factory) {
             $output->writeln('Skipped ' . ($local ? 'local' : 'remote') . ' worker <comment>' . $name . '</comment> from factory <comment>' . $wFactory . '</comment>.');
             continue;
         }
         $factory = $registry->getSharedWorkerFactory($name);
         $profile = $factory->getBootstrapProfile();
         if ($alsoDisable & $local) {
             $this->disableWorker($output, $profile, $name, $wFactory);
         }
         $this->stopWorker($output, $profile, $name, $local, $signal, $wFactory);
     }
 }
Beispiel #2
0
 /**
  * @param string            $name
  * @param string            $wFactory
  * @param int|null          $pid
  * @param string            $socketAddress
  * @param WorkerStatus|null $status
  *
  * @return array
  */
 private function makeRow($name, $wFactory, $pid, $socketAddress, WorkerStatus $status = null)
 {
     $flags = $this->getFlags($name, $pid, IdentificationHelper::isLocalAddress($socketAddress), $status);
     return [implode($flags), $this->makeColoredName($name, $flags), $wFactory, $pid !== null ? strval($pid) : '<fg=blue>unknown</fg=blue>', IdentificationHelper::isNetworkExposedAddress($socketAddress) ? IdentificationHelper::stripScheme($socketAddress) : '<fg=blue>local-only</fg=blue>', $status !== null ? $status->getTextStatus() : '<fg=blue>no data</fg=blue>'];
 }
Beispiel #3
0
 /**
  * @param string                          $socketAddress
  * @param WorkerBootstrapProfile          $bootstrapProfile
  * @param string                          $implementationExpression
  * @param Exception\ConnectException|null $e
  *
  * @throws Exception\ConnectException
  * @throws Exception\LogicException
  */
 public static function startWithExpression($socketAddress, WorkerBootstrapProfile $bootstrapProfile, $implementationExpression, Exception\ConnectException $e = null)
 {
     if (!IdentificationHelper::isLocalAddress($socketAddress)) {
         if ($e) {
             throw $e;
         } else {
             throw new Exception\LogicException("Can't start the worker, because its socket address is not local");
         }
     }
     $bootstrapProfile->getOrFindPhpExecutablePathAndArguments($php, $phpArgs);
     $bootstrapProfile->compileScriptWithExpression($implementationExpression, $socketAddress, $scriptPath, $deleteScript);
     try {
         $line = array_merge([$php], $phpArgs, [$scriptPath]);
         self::startDaemon($line, $bootstrapProfile->getOutputPath());
     } catch (\Exception $e) {
         if ($deleteScript) {
             unlink($scriptPath);
         }
         throw $e;
     }
 }
Beispiel #4
0
 /** {@inheritdoc} */
 public function clear($cacheDir)
 {
     foreach ($this->sharedWorkers as $sharedWorker) {
         $factory = $this->getFactory($sharedWorker[0]);
         if (IdentificationHelper::isLocalAddress($sharedWorker[1])) {
             $factory->stopSharedWorker($sharedWorker[1]);
         }
     }
 }