/** * @param callable $operation * * @throws Exception\LogicException * * @return mixed|$this */ private function transactKillSwitch(callable $operation) { $ksPath = $this->bootstrapProfile->getKillSwitchPath(); if ($ksPath === null) { throw new Exception\LogicException('No kill switch has been configured'); } $lock = Lock::acquire(); $kswitch = new KillSwitch($ksPath); $retval = call_user_func($operation, $kswitch); $kswitch->save(); $lock->release(); return $retval !== null ? $retval : $this; }
/** * @param OutputInterface $output * @param WorkerBootstrapProfile $profile * @param string $name * @param string $wFactory */ private function disableWorker(OutputInterface $output, WorkerBootstrapProfile $profile, $name, $wFactory) { if ($profile->getKillSwitchPath() !== null) { $this->getRegistry()->disableSharedWorker($name); $output->writeln('Disabled local worker <comment>' . $name . '</comment>.'); } else { $output->writeln('Couldn\'t disable local worker <comment>' . $name . '</comment> (please configure a kill switch on factory <comment>' . $wFactory . '</comment> for this feature to work).'); } }