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

Add KSQL Server Docker healthcheck #22

Merged
merged 3 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions cp-ksql-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ RUN chmod +x /etc/confluent/docker/launch
RUN chmod +x /etc/confluent/docker/ensure

CMD ["/etc/confluent/docker/run"]

# Polling period : 5 seconds
# Timeout period :10 seconds (if the polling does not return within this time, treat as a failed poll)
# Start-up period :10 minutes (during which failures are not counted as failures)
# Retry period :30 seconds (after which container is deemed unhealthy)
# All settings can be overriden at run-time in Docker/Docker Compose.
HEALTHCHECK --start-period=600s --interval=5s --timeout=10s --retries=6 \
CMD /etc/confluent/docker/healthcheck.sh
10 changes: 10 additions & 0 deletions cp-ksql-server/include/etc/confluent/docker/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

curl_status=$(curl -X POST -s -o /dev/null -w %{http_code} $KSQL_LISTENERS/ksql -H 'content-type: application/vnd.ksql.v1+json; charset=utf-8' -d '{"ksql":"SHOW TOPICS;"}')
if [ $curl_status -eq 200 ]; then
echo "Woohoo! KSQL is up!"
exit 0
else
echo -e $(date) " KSQL server query response code: " $curl_status " (waiting for 200)"
exit 1
fi