From 2c4423baafe99220cf67ea6d3cf26967ad5734a2 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sat, 9 Oct 2021 17:13:34 -0700 Subject: [PATCH] ttrss: Fix daemon not running sometimes on startup - Sometimes when postgres is not available, the daemon fails to create a database connection. In this case the daemon permanently exits with code 101 instead of trying again. - This happens more prominently when booting the system and postgres may not be available. Although tt-rss.service has Wants= and After= on postgres.service, it appears that postgres does not have proper startup notification with systemd. - This may also happen in other situations such as when temporarily restarting postgres during upgrades or backup/restore operations. - Fix the issue by make the daemon restart after a failure. This seems appropriate because the daemon is coded like a web page to fail and exit on all, even temporary, errors. Tests: - Without the patch, stop postgres@13-main.service. Start tt-rss.service. It will fail permanently and not try to restart. - With the patch, daemon-reload systemd. Notice that the intended changes reflect with systemd status. Start the service. It fails. But retries 2 minutes later with failure again. When postgres is started again, the next attempt succeeds. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- .../usr/lib/systemd/system/tt-rss.service.d/freedombox.conf | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 plinth/modules/ttrss/data/usr/lib/systemd/system/tt-rss.service.d/freedombox.conf diff --git a/plinth/modules/ttrss/data/usr/lib/systemd/system/tt-rss.service.d/freedombox.conf b/plinth/modules/ttrss/data/usr/lib/systemd/system/tt-rss.service.d/freedombox.conf new file mode 100644 index 000000000..ee82c0fc7 --- /dev/null +++ b/plinth/modules/ttrss/data/usr/lib/systemd/system/tt-rss.service.d/freedombox.conf @@ -0,0 +1,6 @@ +# Restart the service every 120 seconds always. When tt-rss can't connect to a +# database temporarily, it will exist with exit code 101. 120 seconds is the +# default daemon sleep interval for tt-rss. +[Service] +Restart=always +RestartSec=120s