Added --all option to stop command
This commit is contained in:
parent
77ef3c2ffa
commit
fa940ab19d
26
README.md
26
README.md
@ -53,3 +53,29 @@ $
|
||||
|
||||
* Data goes in `$HOME/.var/serverctl`
|
||||
|
||||
### How can I tell a container to connect to another container?
|
||||
|
||||
**Static configuration**
|
||||
|
||||
If you need to preconfigure a connection, use the *DOCKER_HOST* environment
|
||||
variable. It will only work in the *environment* section of the service config:
|
||||
|
||||
```json
|
||||
"environment": {
|
||||
"FOO_SERVER": "${DOCKER_HOST}"
|
||||
}
|
||||
```
|
||||
|
||||
**From running container**
|
||||
|
||||
Lookup the IP on your host. On Linux you would do something like:
|
||||
|
||||
```
|
||||
$ ip addr show docker0
|
||||
6: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
|
||||
link/ether 02:42:69:cd:44:2c brd ff:ff:ff:ff:ff:ff
|
||||
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
|
||||
valid_lft forever preferred_lft forever
|
||||
inet6 fe80::42:69ff:fecd:442c/64 scope link
|
||||
valid_lft forever preferred_lft forever
|
||||
```
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user