Skip to content

Commit c674e72

Browse files
authored
Merge pull request #154 from crazy-max/docker-install-stop
docker(install): stop docker daemon gracefully on linux
2 parents 6a8f167 + a72977c commit c674e72

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/docker/assets.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ mkdir -p "$RUNDIR"
7272
echo "Starting dockerd"
7373
set -x
7474
exec dockerd \\
75+
--debug \\
7576
--host="$DOCKER_HOST" \\
7677
--exec-root="$RUNDIR/execroot" \\
7778
--data-root="$RUNDIR/data" \\

src/docker/install.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,17 @@ export class Install {
311311
core.info(fs.readFileSync(path.join(this.runDir, 'dockerd.log'), {encoding: 'utf8'}));
312312
});
313313
await core.group('Stopping Docker daemon', async () => {
314-
await Exec.exec('sudo', ['kill', fs.readFileSync(path.join(this.runDir, 'docker.pid')).toString().trim()]);
314+
await Exec.exec('sudo', ['kill', '-s', 'SIGTERM', fs.readFileSync(path.join(this.runDir, 'docker.pid')).toString().trim()]);
315+
await Util.sleep(5);
315316
});
316317
await core.group('Removing Docker context', async () => {
317318
await Exec.exec('docker', ['context', 'rm', '-f', this.contextName]);
318319
});
319320
await core.group(`Cleaning up runDir`, async () => {
320-
await Exec.exec('sudo', ['rm', '-rf', this.runDir]);
321+
await Exec.exec('sudo', ['rm', '-rf', this.runDir], {
322+
ignoreReturnCode: true,
323+
failOnStdErr: false
324+
});
321325
});
322326
}
323327

src/util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,8 @@ export class Util {
133133
}
134134
return str.substring(0, index);
135135
}
136+
137+
public static sleep(seconds: number) {
138+
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
139+
}
136140
}

0 commit comments

Comments
 (0)