mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-26 22:26:08 +08:00
Merge pull request #154 from crazy-max/docker-install-stop
docker(install): stop docker daemon gracefully on linux
This commit is contained in:
commit
c674e727ec
@ -72,6 +72,7 @@ mkdir -p "$RUNDIR"
|
||||
echo "Starting dockerd"
|
||||
set -x
|
||||
exec dockerd \\
|
||||
--debug \\
|
||||
--host="$DOCKER_HOST" \\
|
||||
--exec-root="$RUNDIR/execroot" \\
|
||||
--data-root="$RUNDIR/data" \\
|
||||
|
@ -311,13 +311,17 @@ export class Install {
|
||||
core.info(fs.readFileSync(path.join(this.runDir, 'dockerd.log'), {encoding: 'utf8'}));
|
||||
});
|
||||
await core.group('Stopping Docker daemon', async () => {
|
||||
await Exec.exec('sudo', ['kill', fs.readFileSync(path.join(this.runDir, 'docker.pid')).toString().trim()]);
|
||||
await Exec.exec('sudo', ['kill', '-s', 'SIGTERM', fs.readFileSync(path.join(this.runDir, 'docker.pid')).toString().trim()]);
|
||||
await Util.sleep(5);
|
||||
});
|
||||
await core.group('Removing Docker context', async () => {
|
||||
await Exec.exec('docker', ['context', 'rm', '-f', this.contextName]);
|
||||
});
|
||||
await core.group(`Cleaning up runDir`, async () => {
|
||||
await Exec.exec('sudo', ['rm', '-rf', this.runDir]);
|
||||
await Exec.exec('sudo', ['rm', '-rf', this.runDir], {
|
||||
ignoreReturnCode: true,
|
||||
failOnStdErr: false
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -133,4 +133,8 @@ export class Util {
|
||||
}
|
||||
return str.substring(0, index);
|
||||
}
|
||||
|
||||
public static sleep(seconds: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user