From 8ebaa4cae47f1d8beb9aa58690c75b706b215b3e Mon Sep 17 00:00:00 2001 From: niten Date: Thu, 12 Oct 2023 14:45:43 -0700 Subject: [PATCH] Add dependencies and health check --- tesla-mate-container.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tesla-mate-container.nix b/tesla-mate-container.nix index a80abe6..99ac055 100644 --- a/tesla-mate-container.nix +++ b/tesla-mate-container.nix @@ -28,6 +28,7 @@ let user = "${toString teslaMateUid}:${toString teslaMateUid}"; env_file = [ teslaMateEnvFile ]; capabilities.ALL = false; + depends_on = { postgres.condition = "service_healthy"; }; }; }; postgres = { @@ -37,6 +38,13 @@ let volumes = [ "${stateDirectory}/postgres:/var/lib/postgresql/data" ]; env_file = [ postgresEnvFile ]; user = "${toString postgresUid}:${toString postgresUid}"; + healthcheck = { + test = [ "CMD" "pg_isready" "-U" "lemmy" "-d" "lemmy" ]; + start_period = "20s"; + interval = "30s"; + retries = 5; + timeout = "3s"; + }; }; }; grafana = { @@ -47,6 +55,7 @@ let env_file = [ grafanaEnvFile ]; user = "${toString grafanaUid}:${toString grafanaUid}"; ports = [ "${toString grafanaPort}:3000" ]; + depends_on = [ "teslamate" ]; }; }; }; @@ -189,7 +198,6 @@ in { [ "fudo-secrets.target" "network-online.target" "podman.service" ]; requires = [ "network-online.target" "podman.service" ]; }; - }; virtualisation.arion.projects.teslamate.settings = let