/** * @param OutputInterface $output * @param WorkerBootstrapProfile $profile * @param string $name * @param bool $local * @param string $wFactory */ private function stopWorkerWithMessage(OutputInterface $output, WorkerBootstrapProfile $profile, $name, $local, $wFactory) { if ($profile->getAdminCookie() !== null) { if ($this->getRegistry()->stopSharedWorker($name)) { $output->writeln('Sent stop message to ' . ($local ? 'local' : 'remote') . ' worker <comment>' . $name . '</comment>.'); } else { $output->writeln(($local ? 'Local' : 'Remote') . ' worker <comment>' . $name . '</comment> was not running.'); } } else { $output->writeln('Couldn\'t send stop message to ' . ($local ? 'local' : 'remote') . ' worker <comment>' . $name . '</comment> (please configure an admin cookie on factory <comment>' . $wFactory . '</comment> for this feature to work).'); } }
/** * @param string $socketAddress * @param WorkerBootstrapProfile $bootstrapProfile * * @throws Exception\LogicException * @throws Exception\RuntimeException * * @return Status\WorkerStatus */ public static function queryWorker($socketAddress, WorkerBootstrapProfile $bootstrapProfile) { $adminCookie = $bootstrapProfile->getAdminCookie(); $channel = self::connect($socketAddress, $bootstrapProfile); AdminEncoding::sendQueryMessage($channel, $adminCookie); for (;;) { $message = $channel->receiveMessage(); $status = AdminEncoding::getStatusMessage($message); if ($status !== null) { return $status; } } }