1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

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.
This commit is contained in:
Alberto Bertogli
2025-08-03 17:45:58 +01:00
parent a9c1f88bd9
commit d0afe102de

View File

@@ -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)
}