From f1f9142a3c9ec062dd0ca222456b24c4a105dac9 Mon Sep 17 00:00:00 2001 From: davidfrickert Date: Tue, 30 Jan 2024 13:47:42 +0000 Subject: [PATCH] fix: Exit docker container on any process exit (#462) ## Description Issue described in #460 ## Changes - Edited `supervisord.conf` to exit if it detects any of the supervisored processes exiting. - minor text fix ## Notes Without this change (or something similar), if act_runner fails, then the container will stay up as a zombie container - it does nothing and does not restart. After this change, if act_runner fails (e.g. due to Gitea instance being down), then supervisord will exit and the container will be restarted. Reviewed-on: https://gitea.com/gitea/act_runner/pulls/462 Reviewed-by: Lunny Xiao Co-authored-by: davidfrickert Co-committed-by: davidfrickert --- internal/pkg/envcheck/docker.go | 2 +- scripts/supervisord.conf | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/pkg/envcheck/docker.go b/internal/pkg/envcheck/docker.go index 0a634ad..65aae4d 100644 --- a/internal/pkg/envcheck/docker.go +++ b/internal/pkg/envcheck/docker.go @@ -27,7 +27,7 @@ func CheckIfDockerRunning(ctx context.Context, configDockerHost string) error { _, err = cli.Ping(ctx) if err != nil { - return fmt.Errorf("cannot ping the docker daemon, does it running? %w", err) + return fmt.Errorf("cannot ping the docker daemon, is it running? %w", err) } return nil diff --git a/scripts/supervisord.conf b/scripts/supervisord.conf index 8c45f5b..6c88f9a 100644 --- a/scripts/supervisord.conf +++ b/scripts/supervisord.conf @@ -11,3 +11,7 @@ stdout_logfile=/dev/fd/1 stdout_logfile_maxbytes=0 redirect_stderr=true command=/opt/act/rootless.sh + +[eventlistener:processes] +command=bash -c "echo READY && read line && kill -SIGQUIT $PPID" +events=PROCESS_STATE_STOPPED,PROCESS_STATE_EXITED,PROCESS_STATE_FATAL \ No newline at end of file