-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add healthchecks to moonraker, klipper and ustreamer images
- Loading branch information
Showing
10 changed files
with
95 additions
and
4 deletions.
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
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,22 @@ | ||
#!/usr/bin/env python3 | ||
import socket, json, sys | ||
|
||
socket_address="/opt/printer_data/run/klipper.sock" | ||
message={"id": 666, "method": "info"} | ||
|
||
# Set up socket connection | ||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
sock.connect(socket_address) | ||
|
||
# Send message and receive response | ||
sock.sendall(json.dumps(message).encode() + b"\x03") | ||
response = sock.recv(4096).decode('utf-8').strip('\x03') | ||
sock.close() | ||
|
||
# Check the result | ||
if json.loads(response)["result"]["state"] == "ready": | ||
# State is ready - healthy | ||
sys.exit(0) | ||
else: | ||
# State is not ready - unhealthy | ||
sys.exit(1) |
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
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,17 @@ | ||
#!/bin/bash | ||
|
||
serverinfo=$(curl -s localhost:7125/server/info) | ||
|
||
klippy_connected=$(echo -n ${serverinfo} | jq -r .result.klippy_connected) | ||
klippy_state=$(echo -n ${serverinfo} | jq -r .result.klippy_state) | ||
failed_components=$(echo -n ${serverinfo} | jq -r .result.failed_components[] | wc -l) | ||
|
||
if [ "$klippy_connected" == "true" ] \ | ||
&& [ "$klippy_state" == "ready" ] \ | ||
&& [ $failed_components -eq 0 ]; then | ||
## moonraker is up and connected to klippy | ||
exit 0 | ||
else | ||
## moonraker started w/ failed components and/or is not connected to klippy | ||
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
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,13 @@ | ||
#!/bin/bash | ||
|
||
state=$(curl -s localhost:8080/state) | ||
ok=$(echo $state | jq -r .ok) | ||
online=$(echo $state | jq -r .result.source.online) | ||
|
||
if [ "$ok" == "true" ] && [ "$online" == "true" ]; then | ||
## ustreamer is ok and source is online | ||
exit 0 | ||
else | ||
## ustreamer is not ok or source is not online | ||
exit 1 | ||
fi |