Skip to content

Commit

Permalink
systemd service: restart less agressively but still quicker
Browse files Browse the repository at this point in the history
If a service fails to start because it's not properly configured (e.g.
directly after installation) the existing settings make the daemons
restart in a loop. Each start logs several lines to the journal
which quickly results in older but probably still relevant logs of other
serives being rotated out.

Dropping RestartSec makes systemd use the default of 100ms. So a restart
happens quicker. With dropping StartLimitInterval=0 systemd applies some
ratelimiting and (by default) only starts the service 5 times per 10s.

Replacing Restart=on-failure by Restart=on-abnormal makes systemd not
restart the service if the daemon process exits with a non-zero exit
code. It's still restarted when the process exits by a signal (other
than SIGHUP, SIGINT, SIGTERM or SIGPIPE).

Debian-Bug: https://bugs.debian.org/1055529
  • Loading branch information
ukleinek committed Nov 16, 2023
1 parent 7b3d7a5 commit 67f9263
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
4 changes: 1 addition & 3 deletions pdns/dnsdistdist/dnsdist.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ User=@service_user@
Group=@service_group@
SyslogIdentifier=dnsdist
Type=notify
Restart=on-failure
RestartSec=2
Restart=on-abnormal
TimeoutStopSec=5
StartLimitInterval=0

# Tuning
TasksMax=8192
Expand Down
4 changes: 1 addition & 3 deletions pdns/ixfrdist.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ After=network-online.target time-sync.target
[Service]
Type=simple
ExecStart=@bindir@/ixfrdist
Restart=on-failure
RestartSec=1
StartLimitInterval=0
Restart=on-abnormal

# Sandboxing
CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID
Expand Down
4 changes: 1 addition & 3 deletions pdns/pdns.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ SyslogIdentifier=pdns_server
User=@service_user@
Group=@service_group@
Type=notify
Restart=on-failure
RestartSec=1
StartLimitInterval=0
Restart=on-abnormal
RuntimeDirectory=pdns

# Sandboxing
Expand Down
3 changes: 1 addition & 2 deletions pdns/recursordist/pdns-recursor.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ ExecStart=@sbindir@/pdns_recursor --daemon=no --write-pid=no --disable-syslog --
User=@service_user@
Group=@service_group@
Type=notify
Restart=on-failure
StartLimitInterval=0
Restart=on-abnormal
RuntimeDirectory=pdns-recursor
SyslogIdentifier=pdns-recursor

Expand Down

0 comments on commit 67f9263

Please sign in to comment.