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
11 changes: 10 additions & 1 deletion tools/local-env/scripts/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,13 @@ const returns = spawnSync(
{ stdio: 'inherit' }
);

process.exit( returns.status );
if ( returns.error ) {
console.error( `Could not run Docker Compose. ${ returns.error.message }` );
} else if ( returns.signal && returns.signal !== 'SIGINT' ) {
console.error( `Docker Compose was terminated by ${ returns.signal }.` );
}

// `status` is null when Docker could not be spawned at all, or was killed by a signal. SIGINT is
// how a long-running command such as `env:logs` is normally ended, so it is not a failure worth an
// npm error block. Every other signal means the command was killed before it finished.
process.exit( returns.signal === 'SIGINT' ? 0 : ( returns.status ?? 1 ) );
13 changes: 12 additions & 1 deletion tools/local-env/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if ( process.env.LOCAL_PHP_MEMCACHED === 'true' ) {
containers.push( 'memcached' );
}

spawnSync(
const up = spawnSync(
'docker',
[
'compose',
Expand All @@ -45,6 +45,17 @@ spawnSync(
{ stdio: 'inherit' }
);

// No signal is exempt here, unlike in `docker.js`: `env:start` runs `composer update -W` next, and
// that must not run against containers that never came up.
if ( up.status !== 0 ) {
const reason = up.signal ? `It was terminated by ${ up.signal }.` : up.error?.message ?? '';

console.error( `Could not start the Docker containers. ${ reason }`.trim() );

// `status` is null when Docker could not be spawned at all, or was killed by a signal.
process.exit( up.status ?? 1 );
}

// If Docker Toolbox is being used, we need to manually forward LOCAL_PORT to the Docker VM.
if ( process.env.DOCKER_TOOLBOX_INSTALL_PATH ) {
// VBoxManage is added to the PATH on every platform except Windows.
Expand Down
Loading