From 1b260823f993a4902f8ef484633d8a7c7552f782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Laitl?= Date: Tue, 11 Jan 2022 19:58:28 +0000 Subject: [PATCH] client, server systemd units: make Restart=always truly respected (#184) Surprisingly, Restart=always may not _always_ restart the unit if it restarts too fast. Set a combination of options which should make systemd truly restart innernet always. See https://unix.stackexchange.com/q/289629/352972. The `RestartSec=60` is the main and important one which would prevent systemd from ever failing to restart innernet in the default settings (because with it it would never exceed the default limit of 5 restarts in 10 seconds). `StartLimitIntervalSec=0` option is a complementary one for explicitly disabling the logic, and may be removed from this PR if deemed unnecessary. --- client/innernet@.service | 4 ++++ server/innernet-server@.service | 2 ++ 2 files changed, 6 insertions(+) diff --git a/client/innernet@.service b/client/innernet@.service index 5c88c30..ea50d21 100644 --- a/client/innernet@.service +++ b/client/innernet@.service @@ -8,6 +8,10 @@ PartOf=innernet.target Type=simple ExecStart=/usr/bin/innernet up %i --daemon --interval 60 Restart=always +# When the daemon exits, wait this amount of secs before restarting. Used to prevent StartLimitBurst +# (5 by default) restarts happening within StartLimitIntervalSec (10 by default) after which systemd +# would refrain from restarting innernet anymore. +RestartSec=10 [Install] WantedBy=multi-user.target diff --git a/server/innernet-server@.service b/server/innernet-server@.service index d4b3a6d..5c3a457 100644 --- a/server/innernet-server@.service +++ b/server/innernet-server@.service @@ -8,6 +8,8 @@ Type=simple Environment="RUST_LOG=info" ExecStart=/usr/bin/innernet-server serve %i Restart=always +# When the daemon exits, wait this amount of secs before restarting instead of default 100ms. +RestartSec=1 [Install] WantedBy=multi-user.target