From d0afe102deff47b840bcdb3d385991afd821a92a Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Sun, 3 Aug 2025 17:45:58 +0100 Subject: [PATCH] chasquid: Exit with code 0 on SIGINT/SIGTERM When we get SIGINT or SIGTERM, today chasquid exits with code 1. This can confuse some of the supervision tools. In particular, Docker and Kubernetes expect exit 0 upon an intentional stop. And systemd, the Restart= semantics make a difference with 0 and non-0, and exiting with 1 prevents users from making that distinction. This patch changes the SIGINT/SIGTERM exit code to 0, to make it easier for users to set up things as desired in those environments. Thanks to [Guiorgy@github](https://github.com/Guiorgy) for reporting this problem in https://github.com/albertito/chasquid/pull/70. --- chasquid.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/chasquid.go b/chasquid.go index a9bef08..18040e2 100644 --- a/chasquid.go +++ b/chasquid.go @@ -247,7 +247,11 @@ func signalHandler(dinfo *domaininfo.DB, srv *smtpsrv.Server) { // Also trigger a server reload. srv.Reload() case syscall.SIGTERM, syscall.SIGINT: - log.Fatalf("Got signal to exit: %v", sig) + log.Infof("Got signal to exit: %v", sig) + // Ideally, we would shutdown the server gracefully, but for now + // we just exit. Note that in practice this is not a significant + // problem, as any in-flight transaction should be retried. + os.Exit(0) default: log.Errorf("Unexpected signal %v", sig) }