diff --git a/docs/README.md b/docs/README.md index 99d923f4..4a244343 100644 --- a/docs/README.md +++ b/docs/README.md @@ -61,7 +61,7 @@ The subdomain used for the project can be configured via the `modules.local-serv * `composer server start [--xdebug=] [--mutagen]` - Starts the containers. * `--xdebug=` will enable Xdebug. The `mode` is optional and defaults to `debug`. Available values are `off`, `develop`, `debug`, `profile`, `coverage`, `gcstats` and `trace`. * `--mutagen` will enable Mutagen for container file sharing. -* `composer server stop` - Stops the containers. +* `composer server stop []` - Stops the containers or specified service. * `composer server restart []` - Restart a given container, or all containers if none is provided. Available values are `nginx`, `php`, `db`, `redis`, `cavalcade`, `tachyon`, `s3` and `elasticsearch`. * `composer server destroy` - Stops and destroys all containers. * `composer server status` - Displays the status of all containers. diff --git a/inc/composer/class-command.php b/inc/composer/class-command.php index 15d93719..8f197659 100644 --- a/inc/composer/class-command.php +++ b/inc/composer/class-command.php @@ -52,10 +52,10 @@ protected function configure() { optionally set the xdebug mode by assigning a value. Passing --mutagen will start the server using Mutagen for file sharing. -Stop the local development server: - stop +Stop the local development server or specific service: + stop [] Restart the local development server: - restart [--xdebug=] passing --xdebug restarts the server with xdebug enabled + restart [--xdebug=] [] passing --xdebug restarts the server with xdebug enabled Destroy the local development server: destroy View status of the local development server: @@ -278,24 +278,33 @@ protected function start( InputInterface $input, OutputInterface $output ) { protected function stop( InputInterface $input, OutputInterface $output ) { $output->writeln( 'Stopping...' ); - $compose = new Process( $this->get_compose_command( 'stop', true ), 'vendor', $this->get_env() ); - $compose->setTty( posix_isatty( STDOUT ) ); + $options = $input->getArgument( 'options' ); + if ( isset( $options[0] ) ) { + $service = $options[0]; + } else { + $service = ''; + } + + $compose = new Process( $this->get_compose_command( "stop $service", true ), 'vendor', $this->get_env() ); $compose->setTimeout( 0 ); + $compose->setTty( posix_isatty( STDOUT ) ); $return_val = $compose->run( function ( $type, $buffer ) { echo $buffer; } ); - $proxy = new Process( $this->get_compose_command( '-f proxy.yml stop' ), 'vendor/altis/local-server/docker' ); - $proxy->setTimeout( 0 ); - $proxy->setTty( posix_isatty( STDOUT ) ); - $proxy->run( function ( $type, $buffer ) { - echo $buffer; - } ); + if ( $service === '' ) { + $proxy = new Process( $this->get_compose_command( '-f proxy.yml stop' ), 'vendor/altis/local-server/docker' ); + $proxy->setTimeout( 0 ); + $proxy->setTty( posix_isatty( STDOUT ) ); + $proxy->run( function ( $type, $buffer ) { + echo $buffer; + } ); + } if ( $return_val === 0 ) { $output->writeln( 'Stopped.' ); } else { - $output->writeln( 'Failed to stop services.' ); + $output->writeln( 'Failed to stop service(s).' ); } return $return_val;