Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): add Bash healthcheck script #14704

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion server/bin/immich-healthcheck
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
#!/usr/bin/env bash

node /usr/src/app/dist/bin/healthcheck.js
if [[ "$IMMICH_WORKERS_EXCLUDE" == *"api"* ]] ||
[[ "$IMMICH_WORKERS_INCLUDE" != *"api"* ]]; then
000yesnt marked this conversation as resolved.
Show resolved Hide resolved
echo "API worker excluded, skipping";
exit 0;
fi

IMMICH_HOST="${IMMICH_HOST:=localhost}"
000yesnt marked this conversation as resolved.
Show resolved Hide resolved
IMMICH_PORT="${IMMICH_PORT:=2283}"

result=$(curl -m 2 http://"$IMMICH_HOST":"$IMMICH_PORT"/api/server/ping)
000yesnt marked this conversation as resolved.
Show resolved Hide resolved
result_exit=$?

if ! [ $result_exit == 0 ]; then
000yesnt marked this conversation as resolved.
Show resolved Hide resolved
echo "Fail: exit code is $result_exit";
exit 1;
fi

if ! [ "$result" == "{\"res\":\"pong\"}" ]; then
000yesnt marked this conversation as resolved.
Show resolved Hide resolved
echo "Fail: didn't reply with pong";
exit 1;
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would explicitly exit 0 at the end of the script. Otherwise looks good to me. Ty!

Loading