From c80837f48166fc6cdae8f5d582b280bb265bbb7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Mon, 19 Dec 2022 02:08:36 +0100 Subject: [PATCH] Add healthcheck program --- discord_rss_bot/healthcheck.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 discord_rss_bot/healthcheck.py diff --git a/discord_rss_bot/healthcheck.py b/discord_rss_bot/healthcheck.py new file mode 100644 index 0000000..855ce42 --- /dev/null +++ b/discord_rss_bot/healthcheck.py @@ -0,0 +1,20 @@ +"""This is used as a healthcheck in the Dockerfile. +The normal way would probably be to use CURL, but then we would have to install it.""" + +import sys + +import requests + + +def healthcheck(): + """Check if the website is up.""" + try: + r = requests.get("http://localhost:5000") + if r.ok: + sys.exit(1) + except requests.exceptions.RequestException: + sys.exit(0) + + +if __name__ == "__main__": + healthcheck()