Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Service_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public function enable( $args, $assoc_args ) {
EE::Log( 'Notice: Service nginx_proxy already enabled.' );
}
} else {
$service_status = \EE\Service\Utils\init_global_container( $service );
// Recreate, not `docker start`: an upgrade leaves a stopped service on its old image for this to move.
$service_status = \EE\Service\Utils\init_global_container( $service, '', true );
if ( $service_status ) {
EE::success( sprintf( 'Service %s enabled.', $service ) );
} else {
Expand Down
12 changes: 10 additions & 2 deletions src/helper/service-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ function nginx_proxy_check() {
* Function to start global conainer if it is not running.
*
* @param string $container Global container to be brought up.
* @param bool $recreate `up -d` a stopped container too, which recreates it when the compose file changed (e.g. its image).
*/
function init_global_container( $service, $container = '' ) {
function init_global_container( $service, $container = '', $recreate = false ) {

if ( empty( $container ) ) {
$container = 'services_' . $service . '_1';
Expand All @@ -96,7 +97,14 @@ function init_global_container( $service, $container = '' ) {
if ( IS_DARWIN && GLOBAL_DB === $service && ! $fs->exists( $db_conf_file ) ) {
$fs->copy( SERVICE_TEMPLATE_ROOT . '/my.cnf.mustache', $db_conf_file );
}
\EE_DOCKER::boot_container( $container, \EE_DOCKER::docker_compose_with_custom() . ' up -d ' . $service );
$up = \EE_DOCKER::docker_compose_with_custom() . ' up -d ' . $service;
if ( $recreate ) {
if ( ! EE::exec( $up ) ) {
EE::error( "There was some error in starting $container. Please check logs." );
}
} else {
\EE_DOCKER::boot_container( $container, $up );
}
return true;
} else {
return false;
Expand Down