diff --git a/cmd/agent/main.go b/cmd/agent/main.go index a1fec982c..a3aafb948 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -28,7 +28,7 @@ func main() { ctx, cancel := context.WithCancel(context.Background()) sigChan := make(chan os.Signal, 1) - signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) + signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) go func() { select { case <-sigChan: diff --git a/internal/config/config.go b/internal/config/config.go index c420e9073..0861c2f7f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -87,9 +87,10 @@ func ResolveConfig() (*Config, error) { dir += "/" } allowedDirs = append(allowedDirs, dir) - slog.Info("Configured allowed directories", "allowed_directories", allowedDirs) } + slog.Info("Configured allowed directories", "allowed_directories", allowedDirs) + // Collect all parsing errors before returning the error, so the user sees all issues with config // in one error message. var err error diff --git a/test/docker/entrypoint.sh b/test/docker/entrypoint.sh index 93920d97d..24b82bc04 100644 --- a/test/docker/entrypoint.sh +++ b/test/docker/entrypoint.sh @@ -2,16 +2,28 @@ set -euxo pipefail -handle_term() -{ +handle_term() { echo "received TERM signal" echo "stopping nginx-agent ..." kill -TERM "${agent_pid}" 2>/dev/null + wait -n ${agent_pid} echo "stopping nginx ..." kill -TERM "${nginx_pid}" 2>/dev/null + wait -n ${nginx_pid} +} + +handle_quit() { + echo "received QUIT signal" + echo "stopping nginx-agent ..." + kill -QUIT "${agent_pid}" 2>/dev/null + wait -n ${agent_pid} + echo "stopping nginx ..." + kill -QUIT "${nginx_pid}" 2>/dev/null + wait -n ${nginx_pid} } -trap 'handle_term' TERM +trap 'handle_term' TERM +trap 'handle_quit' QUIT # Launch nginx echo "starting nginx ..." diff --git a/test/docker/nginxless-entrypoint.sh b/test/docker/nginxless-entrypoint.sh index b971d9108..ee76a2893 100644 --- a/test/docker/nginxless-entrypoint.sh +++ b/test/docker/nginxless-entrypoint.sh @@ -7,9 +7,18 @@ handle_term() echo "received TERM signal" echo "stopping nginx-agent ..." kill -TERM "${agent_pid}" 2>/dev/null + wait -n ${agent_pid} } -trap 'handle_term' TERM +handle_quit() { + echo "received QUIT signal" + echo "stopping nginx-agent ..." + kill -QUIT "${agent_pid}" 2>/dev/null + wait -n ${agent_pid} +} + +trap 'handle_term' TERM +trap 'handle_quit' QUIT cat /etc/nginx-agent/nginx-agent.conf;