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

Healthcheck using Host and Port from zoo.cfg #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ WORKDIR /opt/zookeeper

# Only checks if server is up and listening, not quorum.
# See https://zookeeper.apache.org/doc/r3.4.13/zookeeperAdmin.html#sc_zkCommands
HEALTHCHECK CMD [ $(echo ruok | nc 127.0.0.1:2181) == "imok" ] || exit 1
COPY healthcheck /healthcheck
HEALTHCHECK CMD /healthcheck

VOLUME ["/opt/zookeeper/conf", "/tmp/zookeeper"]

Expand Down
11 changes: 11 additions & 0 deletions healthcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# Read bound host and port from the config file (if any)
set -e

CFG=/opt/zookeeper/conf/zoo.cfg
if [ -e "$CFG" ]; then
H="$(awk -F= '/^clientPortAddress=/{ print $2 }' "$CFG")"
P="$(awk -F= '/^clientPort=/{ print $2 }' "$CFG")"
fi

[ "$(echo ruok | nc "${H:-127.0.0.1}" "${P:-2181}")" == "imok" ] || exit 1