We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a7c9418 commit 1095b85Copy full SHA for 1095b85
images/cgimap/liveness.sh
@@ -0,0 +1,17 @@
1
+#!/usr/bin/env bash
2
+pgrep -f openstreetmap-cgimap > /dev/null
3
+cgimap_status=$?
4
+
5
+# Check PostgreSQL connection
6
+PGPASSWORD="$POSTGRES_PASSWORD" psql -h "$POSTGRES_HOST" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 1;" > /dev/null 2>&1
7
+postgres_status=$?
8
9
+# Exit code logic
10
+if [ $cgimap_status -eq 0 ] && [ $postgres_status -eq 0 ]; then
11
+ echo "cgimap and PostgreSQL are healthy"
12
+ exit 0
13
+else
14
+ [ $cgimap_status -ne 0 ] && echo "cgimap not running" >&2
15
+ [ $postgres_status -ne 0 ] && echo "cannot connect to PostgreSQL" >&2
16
+ exit 1
17
+fi
0 commit comments