From a42ab1510bb28c4073dbc54a51a89106bd88eb35 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Thu, 14 May 2020 09:59:09 +0200 Subject: [PATCH] Use docker-compose restarts This means restarting is a lot faster, and also means we can now restart individual services. --- inc/composer/class-command.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/inc/composer/class-command.php b/inc/composer/class-command.php index ed5cf846..0896fccd 100644 --- a/inc/composer/class-command.php +++ b/inc/composer/class-command.php @@ -233,8 +233,32 @@ protected function destroy( InputInterface $input, OutputInterface $output ) { } protected function restart( InputInterface $input, OutputInterface $output ) { - $this->stop( $input, $output ); - return $this->start( $input, $output ); + $output->writeln( 'Restarting...' ); + + $proxy = new Process( 'docker-compose restart', 'vendor/altis/local-server/docker' ); + $proxy->run(); + + $options = $input->getArgument( 'options' ); + if ( isset( $options[0] ) ) { + $service = $options[0]; + } else { + $service = ''; + } + $compose = new Process( "docker-compose restart $service", 'vendor/altis/local-server/docker', [ + 'VOLUME' => getcwd(), + 'COMPOSE_PROJECT_NAME' => $this->get_project_subdomain(), + ] ); + $return_val = $compose->run( function ( $type, $buffer ) { + echo $buffer; + } ); + + if ( $return_val === 0 ) { + $output->writeln( 'Restarted.' ); + } else { + $output->writeln( 'Failed to restart services.' ); + } + + return $return_val; } protected function exec( InputInterface $input, OutputInterface $output, ?string $program = null ) {