nixpkgs/nixos/modules
Maximilian Bosch e7533df80f
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.
2024-03-22 17:51:20 +01:00
..
config nixos/nix: Fix example for nix.settings option 2024-03-19 22:55:19 +01:00
hardware Add ivsc-firmware to ipu6 option 2024-03-15 09:29:46 -05:00
i18n/input-method nixos/fcitx5: fix warning about plasma6 option 2024-03-20 15:18:51 +01:00
image nixos/repart-image: add myself as maintainer 2024-03-21 11:37:43 +01:00
installer nixos/iso-image: extremely cursed performance optimization for Hydra 2024-03-12 15:41:59 +03:00
misc nixos/mandoc: add leading slash to manPath 2024-03-20 00:56:18 +01:00
profiles nixos/hardened: update hardened profile to new recommendations 2024-01-27 20:43:58 +00:00
programs nixos/starship: cleanup 2024-03-20 21:08:43 +11:00
security Merge pull request #291951 from amarshall/zfs-pkgs-renaming 2024-03-01 10:09:12 -05:00
services nixos/mastodon: stop mastodon-init-db.service if check for seeded DB fails 2024-03-22 17:51:20 +01:00
system Merge #284149: nixos/kernel: add hid_corsair to initrd modules 2024-03-22 14:59:18 +01:00
tasks Add missing closing parens. 2024-03-02 12:40:40 +01:00
testing nixos/test-instrumentation: use full path to env 2024-03-04 16:12:56 +01:00
virtualisation Merge pull request #224666 from grindhold/container_underscores 2024-03-20 11:41:34 +02:00
module-list.nix Merge pull request #294171 from Noodlez1232/joycond-cemuhook-fix 2024-03-22 00:40:59 +01:00
rename.nix restya-board: drop 2024-02-07 01:33:05 +01:00