Skip to content

Instantly share code, notes, and snippets.

@Schnouki
Created April 26, 2023 12:47
Show Gist options
  • Save Schnouki/f2116d291b956bf9d51497031b0ae357 to your computer and use it in GitHub Desktop.
Save Schnouki/f2116d291b956bf9d51497031b0ae357 to your computer and use it in GitHub Desktop.
sqs-worker-pool healthcheck test scripts
#!/usr/bin/env python
import socket
import sys
def main():
socket_path = sys.argv[1]
with socket.socket(socket.AF_UNIX) as s:
s.connect(socket_path)
s.sendall(b"CHECK\n")
resp = s.recv(1024).strip()
success = resp.startswith(b"OK ")
sys.exit(0 if success else 1)
if __name__ == "__main__":
main()
#!/usr/bin/env bash
echo "$$ starting"
echo "$$ args: $@"
echo "$$ socket: ${HEALTHCHECK_SOCKET}"
sleep 10
echo "$$ reporting as healthy"
echo "SET $$" | nc -U ${HEALTHCHECK_SOCKET}
while true; do
sleep 100
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment