summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/rangehttpserver
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2024-03-22 16:53:27 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2024-03-22 17:51:20 +0100
commite7533df80fd18b4a06b44142e863738c3f3bced5 (patch)
tree8b2a233f6c01138076ab7b99ff183f9c7d87dda6 /pkgs/development/python-modules/rangehttpserver
parent732cd2b4b8107fc8975318dba7e90e33c29ec11a (diff)
nixos/mastodon: stop mastodon-init-db.service if check for seeded DB fails
The postgresql runs on a different node than my mastodon itself. Sometimes when rebooting the entire host it can happen that mastodon gets started before the DB[1] is up. In that case `mastodon-init-db.service` ran through with the following log output: 2024-03-07 15:30:56.856 Migrating database (this might be a noop) 2024-03-07 15:30:56.856 /nix/store/xzm7www0qb7jg5zrgg7knynckx5yhki9-unit-script-mastodon-init-db-start/bin/mastodon-init-db-start: line 9: [: -eq: unary operator expected It seems wrong to me to have this unit pass if the DB isn't even up, especially with such an error. This patch now checks if the exit code of the psql check was non-zero and fails the entire unit. A retry can be implemented e.g. with Restart/RestartSec then (which is more elegant than adding a while/sleep loop anyways) like this: systemd.services.mastodon-init-db = { serviceConfig = { Restart = "on-failure"; RestartSec = "5s"; RestartMode = "direct"; RemainAfterExit = true; }; unitConfig = { StartLimitBurst = 5; StartLimitIntervalSec = "60"; }; }; Also using `-t --csv` now to not render the column name and to not render a table so we don't need to rely on the format of psql (and parse it with `sed(1)`). [1] I added a script that blocks until postgres is there in the meantime though.
Diffstat (limited to 'pkgs/development/python-modules/rangehttpserver')
0 files changed, 0 insertions, 0 deletions