From a9ee4f5b39ad47d3ba7d5d91a34fae1268b4d4fb Mon Sep 17 00:00:00 2001 From: Matt Domsch Date: Thu, 24 Feb 2022 15:51:32 -0600 Subject: [PATCH 1/2] systemd: use Type=simple and no fork to avoid PIDFile race --- contrib/service/opendmarc.service.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/service/opendmarc.service.in b/contrib/service/opendmarc.service.in index 2e1cf20e..307a2328 100644 --- a/contrib/service/opendmarc.service.in +++ b/contrib/service/opendmarc.service.in @@ -4,10 +4,9 @@ Documentation=man:opendmarc(8) man:opendmarc.conf(5) man:opendmarc-import(8) man After=network.target nss-lookup.target syslog.target [Service] -Type=forking -PIDFile=@localstatedir@/run/opendmarc/opendmarc.pid +Type=simple EnvironmentFile=-@sysconfdir@/sysconfig/opendmarc -ExecStart=@sbindir@/opendmarc $OPTIONS +ExecStart=@sbindir@/opendmarc -f $OPTIONS ExecReload=/bin/kill -USR1 $MAINPID User=opendmarc Group=opendmarc From ae2849930362a86f92ad538a7258d9bc6f767534 Mon Sep 17 00:00:00 2001 From: Matt Domsch Date: Thu, 24 Feb 2022 22:56:20 -0600 Subject: [PATCH 2/2] systemd: add Restart=on-abnormal This is a long-running process that once started by systemd should stay running forever. In the event of a fatal error and unclean exit, we want systemd to restart the program. We use on-abnormal because there are valid nonzero exit codes (EX_USAGE, EX_OSERR, EX_CONFIG) which the program can properly return indicating a configuration or command line error, or inability to allocate memory early on. In these events, restarting would be inappropriate, but on-failure would try anyhow. --- contrib/service/opendmarc.service.in | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/service/opendmarc.service.in b/contrib/service/opendmarc.service.in index 307a2328..20390ec3 100644 --- a/contrib/service/opendmarc.service.in +++ b/contrib/service/opendmarc.service.in @@ -8,6 +8,7 @@ Type=simple EnvironmentFile=-@sysconfdir@/sysconfig/opendmarc ExecStart=@sbindir@/opendmarc -f $OPTIONS ExecReload=/bin/kill -USR1 $MAINPID +Restart=on-abnormal User=opendmarc Group=opendmarc