docker 优雅关闭(docker stop graceful) (#2827)

This commit is contained in:
xiongguangjie
2023-09-09 10:59:27 +08:00
committed by GitHub
parent f26e25323f
commit f69f3b3029
8 changed files with 18 additions and 6 deletions

View File

@@ -126,6 +126,12 @@ void System::startDaemon(bool &kill_parent_if_failed) {
exit(0);
});
signal(SIGTERM,[](int) {
WarnL << "收到主动退出信号,关闭父进程与子进程";
kill(pid, SIGINT);
exit(0);
});
do {
int status = 0;
if (waitpid(pid, &status, 0) >= 0) {