mirror of
https://github.com/juspay/services-flake.git
synced 2024-09-17 15:28:33 +03:00
postgres: readiness probe
This commit is contained in:
parent
27c3221de2
commit
20b63ecf79
@ -270,8 +270,9 @@ in
|
||||
text = ''
|
||||
set -x
|
||||
export PATH="${postgresPkg}"/bin:$PATH
|
||||
export LOCKDIR="/tmp"
|
||||
postgres -k "$LOCKDIR" -D ${cfg.dataDir}
|
||||
PGDATA=$(readlink -f "${cfg.dataDir}")
|
||||
export PGDATA
|
||||
postgres -k "$PGDATA"
|
||||
'';
|
||||
};
|
||||
in
|
||||
@ -280,6 +281,14 @@ in
|
||||
depends_on."${cfg.name}-init".condition = "process_completed_successfully";
|
||||
# SIGINT (= 2) for faster shutdown: https://www.postgresql.org/docs/current/server-shutdown.html
|
||||
shutdown.signal = 2;
|
||||
readiness_probe = {
|
||||
exec.command = "${postgresPkg}/bin/pg_isready -h $(readlink -f ${cfg.dataDir}) -d template1";
|
||||
initial_delay_seconds = 2;
|
||||
period_seconds = 10;
|
||||
timeout_seconds = 4;
|
||||
success_threshold = 1;
|
||||
failure_threshold = 5;
|
||||
};
|
||||
# https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy
|
||||
availability.restart = "on_failure";
|
||||
};
|
||||
|
@ -5,6 +5,7 @@
|
||||
};
|
||||
testScript = ''
|
||||
process_compose.wait_until(lambda procs:
|
||||
# TODO: Check for 'ready'
|
||||
procs["postgres"]["status"] == "Running"
|
||||
)
|
||||
machine.succeed("echo 'SELECT version();' | ${config.services.postgres.package}/bin/psql -h 127.0.0.1 -U tester")
|
||||
|
Loading…
Reference in New Issue
Block a user