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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2021-10-09 17:13:34 -07:00 committed by James Valleroy
parent 9bd1f80d5c
commit 2c4423baaf
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -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