Skip to content

Commit

Permalink
systemd: improve restarting daemon
Browse files Browse the repository at this point in the history
- add After=local-fs.target
- place StartLimitBurst=10 in service part instead unit
- replace generic exit 1 by the specific configuration error
 exit code 42 and wrong command line parameter 41
- add comment about how to reset failed counter
- reformat debian filedaemon service file

Signed-off-by: Bruno Friedmann <bruno.friedmann@bareos.com>
  • Loading branch information
bruno-at-bareos authored and alaaeddineelamri committed Sep 20, 2023
1 parent 67a934c commit 293a8f8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 26 deletions.
9 changes: 5 additions & 4 deletions core/platforms/systemd/bareos-dir.service.in
Expand Up @@ -6,15 +6,14 @@
Description=Bareos Director Daemon service
Documentation=man:bareos-dir(8)
Requires=network.target nss-lookup.target time-sync.target
After=network-online.target nss-lookup.target remote-fs.target time-sync.target postgresql.service
After=network-online.target nss-lookup.target local-fs.target remote-fs.target time-sync.target postgresql.service
# Dependency about the database
# We let administrators decide if they need it (if local db instance)
# Wants=@DEFAULT_DB_TYPE@.service
# Check if working dir exist
ConditionPathExists=@working_dir@
# Limit the number of restart per day to 10
# Limit the number of restart per day
StartLimitIntervalSec=1d
StartLimitBurst=10

[Service]
Type=simple
Expand All @@ -30,8 +29,10 @@ LimitNOFILE=8192:524288
# Restart on failure, wait 30 seconds
Restart=on-failure
RestartSec=30
# Limit the number of restart to 10. to reset counter use systemctl reset-failed bareos-dir
StartLimitBurst=10
# Don't restart on wrong exec arguments and configuration errors.
RestartPreventExitStatus=109 1
RestartPreventExitStatus=41 42


[Install]
Expand Down
9 changes: 5 additions & 4 deletions core/platforms/systemd/bareos-fd.service.in
Expand Up @@ -6,12 +6,11 @@
Description=Bareos File Daemon service
Documentation=man:bareos-fd(8)
Requires=network.target nss-lookup.target time-sync.target
After=network-online.target nss-lookup.target remote-fs.target time-sync.target
After=network-online.target nss-lookup.target local-fs.target remote-fs.target time-sync.target
# Check if working dir exist
ConditionPathExists=@working_dir@
# Limit the number of restart per day to 10
# Limit the number of restart per day
StartLimitIntervalSec=1d
StartLimitBurst=10

[Service]
Type=simple
Expand All @@ -26,8 +25,10 @@ LimitNOFILE=8192:524288
# Restart on failure, wait 30 seconds
Restart=on-failure
RestartSec=30
# Limit the number of restart to 10. to reset counter use systemctl reset-failed bareos-fd
StartLimitBurst=10
# Don't restart on wrong exec arguments and configuration errors.
RestartPreventExitStatus=109 1
RestartPreventExitStatus=41 42


[Install]
Expand Down
11 changes: 6 additions & 5 deletions core/platforms/systemd/bareos-sd.service.in
Expand Up @@ -6,12 +6,11 @@
Description=Bareos Storage Daemon service
Documentation=man:bareos-sd(8)
Requires=network.target nss-lookup.target time-sync.target
After=network-online.target nss-lookup.target remote-fs.target time-sync.target
After=network-online.target nss-lookup.target local-fs.target remote-fs.target time-sync.target
# Check if working dir exist
ConditionPathExists=@working_dir@
# Limit the number of restart per day to 10
# Limit the number of restart per day
StartLimitIntervalSec=1d
StartLimitBurst=10

[Service]
Type=simple
Expand All @@ -20,13 +19,15 @@ Group=@sd_group@
WorkingDirectory=@working_dir@
ExecStart=@sbindir@/bareos-sd -f
SuccessExitStatus=0 15
# Increase the the maximum number of open file descriptors
# Increase the maximum number of open file descriptors
LimitNOFILE=8192:524288
# Restart on failure, wait 30 seconds
Restart=on-failure
RestartSec=30
# Limit the number of restart to 10. to reset counter use systemctl reset-failed bareos-fd
StartLimitBurst=10
# Don't restart on wrong exec arguments and configuration errors.
RestartPreventExitStatus=109 1
RestartPreventExitStatus=41 42


[Install]
Expand Down
9 changes: 5 additions & 4 deletions debian/bareos-director.service.in
Expand Up @@ -6,15 +6,14 @@
Description=Bareos Director Daemon service
Documentation=man:bareos-dir(8)
Requires=network.target nss-lookup.target time-sync.target
After=network-online.target nss-lookup.target remote-fs.target time-sync.target postgresql.service
After=network-online.target nss-lookup.target local-fs.target remote-fs.target time-sync.target postgresql.service
# Dependency about the database
# We let administrators decide if they need it (if local db instance)
# Wants=@DEFAULT_DB_TYPE@.service
# Check if working dir exist
ConditionPathExists=@working_dir@
# Limit the number of restart per day to 10
# Limit the number of restart per day
StartLimitIntervalSec=1d
StartLimitBurst=10

[Service]
Type=simple
Expand All @@ -30,8 +29,10 @@ LimitNOFILE=8192:524288
# Restart on failure, wait 30 seconds
Restart=on-failure
RestartSec=30
# Limit the number of restart to 10. to reset counter use systemctl reset-failed bareos-director
StartLimitBurst=10
# Don't restart on wrong exec arguments and configuration errors.
RestartPreventExitStatus=109 1
RestartPreventExitStatus=41 42

[Install]
Alias=bareos-dir.service
Expand Down
9 changes: 5 additions & 4 deletions debian/bareos-filedaemon.service.in
Expand Up @@ -6,12 +6,11 @@
Description=Bareos File Daemon service
Documentation=man:bareos-fd(8)
Requires=network.target nss-lookup.target time-sync.target
After=network-online.target nss-lookup.target local-fs.target remote-fs.target time-sync.target
# Check if working dir exist
ConditionPathExists=@working_dir@
# Limit the number of restart per day to 10
# Limit the number of restart per day
StartLimitIntervalSec=1d
StartLimitBurst=10
After=network-online.target nss-lookup.target remote-fs.target time-sync.target

[Service]
Type=simple
Expand All @@ -26,8 +25,10 @@ LimitNOFILE=8192:524288
# Restart on failure, wait 30 seconds
Restart=on-failure
RestartSec=30
# Limit the number of restart to 10. to reset counter use systemctl reset-failed bareos-filedaemon
StartLimitBurst=10
# Don't restart on wrong exec arguments and configuration errors.
RestartPreventExitStatus=109 1
RestartPreventExitStatus=41 42


[Install]
Expand Down
11 changes: 6 additions & 5 deletions debian/bareos-storage.service.in
Expand Up @@ -6,12 +6,11 @@
Description=Bareos Storage Daemon service
Documentation=man:bareos-sd(8)
Requires=network.target nss-lookup.target time-sync.target
After=network-online.target nss-lookup.target remote-fs.target time-sync.target
After=network-online.target nss-lookup.target local-fs.target remote-fs.target time-sync.target
# Check if working dir exist
ConditionPathExists=@working_dir@
# Limit the number of restart per day to 10
# Limit the number of restart per day
StartLimitIntervalSec=1d
StartLimitBurst=10

[Service]
Type=simple
Expand All @@ -20,13 +19,15 @@ Group=@sd_group@
WorkingDirectory=@working_dir@
ExecStart=@sbindir@/bareos-sd -f
SuccessExitStatus=0 15
# Increase the maximum number of open file descriptors```
# Increase the maximum number of open file descriptors
LimitNOFILE=8192:524288
# Restart on failure, wait 30 seconds
Restart=on-failure
RestartSec=30
# Limit the number of restart to 10. to reset counter use systemctl reset-failed bareos-storage
StartLimitBurst=10
# Don't restart on wrong exec arguments and configuration errors.
RestartPreventExitStatus=109 1
RestartPreventExitStatus=41 42

[Install]
Alias=bareos-sd.service
Expand Down

0 comments on commit 293a8f8

Please sign in to comment.