-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a healthcheck to the Docker container image
- Loading branch information
1 parent
74f499b
commit 50fbb46
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
function get_property() { | ||
grep "^$1=" "$2" | cut -d'=' -f2 | ||
} | ||
|
||
scheme=http | ||
port=8080 | ||
|
||
config=/etc/trino/config.properties | ||
# prefer to use http even if https is enabled | ||
if [ "$(get_property 'http-server.http.enabled' "$config")" == "false" ]; then | ||
scheme=https | ||
port=$(get_property http-server.https.port "$config") | ||
else | ||
port=$(get_property http-server.http.port "$config") | ||
fi | ||
|
||
endpoint="$scheme://localhost:$port/v1/info" | ||
|
||
# add --insecure to disable certificate verification in curl, in case a self-signed certificate is being used | ||
if ! info=$(curl --fail --silent --show-error --insecure "$endpoint"); then | ||
echo >&2 "Server is not responding to requests" | ||
exit 1 | ||
fi | ||
|
||
if ! grep -q '"starting":\s*false' <<<"$info" >/dev/null; then | ||
echo >&2 "Server is starting" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters