[Postgres]: Fix test process not starting (#78)

* needn't copy depends_on option, demonstrated in example/flake.nix

* postgres: test process must depend on both pg1 and pg2
This commit is contained in:
Shivaraj B H 2024-01-18 11:28:15 +05:30 committed by GitHub
parent 5365c6a4dd
commit bf3a582502
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 20 deletions

View File

@ -43,6 +43,8 @@
listen_addresses = "127.0.0.1";
port = 5433;
};
# Start `pg2-init` process after `pg1-init`
settings.processes."pg2-init".depends_on."pg1-init".condition = "process_completed_successfully";
settings.processes.pgweb =
let

View File

@ -230,24 +230,6 @@ in
'';
};
depends_on = lib.mkOption {
description = "Extra process dependency relationships for `${name}-init` process.";
type = types.nullOr (types.attrsOf (types.submodule {
options = {
condition = lib.mkOption {
type = types.enum [
"process_completed"
"process_completed_successfully"
"process_healthy"
"process_started"
];
example = "process_healthy";
};
};
}));
default = null;
};
initialScript = lib.mkOption {
type = types.submodule ({ config, ... }: {
options = {
@ -298,7 +280,6 @@ in
in
{
command = setupScript;
depends_on = config.depends_on;
namespace = name;
};

View File

@ -17,6 +17,8 @@
}
];
};
# avoid both the processes trying to create `data` directory at the same time
settings.processes."pg2-init".depends_on."pg1-init".condition = "process_completed_successfully";
settings.processes.test =
let
cfg = config.services.postgres."pg1";
@ -39,6 +41,9 @@
'';
name = "postgres-test";
};
depends_on."pg1".condition = "process_healthy";
depends_on = {
"pg1".condition = "process_healthy";
"pg2".condition = "process_healthy";
};
};
}