Added --all option to stop command
This commit is contained in:
@ -16,8 +16,9 @@ class StopCommand extends Command
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->addOption("all", "A", InputOption::VALUE_NONE, "Stop all services");
|
||||
$this->addOption("instance", "i", InputOption::VALUE_REQUIRED, "Specify the instance name", "default");
|
||||
$this->addArgument("service", InputArgument::REQUIRED, "The service name");
|
||||
$this->addArgument("service", InputArgument::OPTIONAL, "The service name");
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
@ -28,6 +29,26 @@ class StopCommand extends Command
|
||||
|
||||
$serviceName = $input->getArgument("service");
|
||||
$instanceName = $input->getOption("instance");
|
||||
$stopAll = $input->getOption("all");
|
||||
|
||||
if (!($instanceName || $stopAll)) {
|
||||
$output->writeln("<error>You need to specify a service, or --all</>");
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
if ($stopAll) {
|
||||
$services = $containerManager->getRunningServices();
|
||||
foreach ($services as $service) {
|
||||
$output->write("Stopping...\r");
|
||||
try {
|
||||
$containerManager->stopService($service['service'], $service['instance']);
|
||||
$output->writeln("Stopped service <fg=cyan>".$service['service']['name']."</>[<fg=cyan>".$service['instance']."</>]");
|
||||
} catch (RuntimeException $e) {
|
||||
$output->writeln("<error>".$e->getMessage()."</>");
|
||||
}
|
||||
}
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$serviceInfo = $serviceRegistry->findServiceByName($serviceName);
|
||||
if (!$serviceInfo) {
|
||||
|
Reference in New Issue
Block a user