2022-10-22 20:00:13 -08:00
|
|
|
import os
|
2024-01-11 17:11:42 -06:00
|
|
|
import sys
|
2022-10-22 20:00:13 -08:00
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
port = os.getenv("API_PORT")
|
|
|
|
|
|
|
|
|
|
if port is None:
|
|
|
|
|
port = 9000
|
|
|
|
|
|
2024-11-11 17:58:12 +01:00
|
|
|
if all(os.getenv(x) for x in ["TLS_CERTIFICATE_PATH", "TLS_PRIVATE_KEY_PATH"]):
|
|
|
|
|
proto = "https"
|
|
|
|
|
else:
|
|
|
|
|
proto = "http"
|
|
|
|
|
|
|
|
|
|
url = f"{proto}://127.0.0.1:{port}/api/app/about"
|
2022-10-22 20:00:13 -08:00
|
|
|
|
2024-11-11 17:58:12 +01:00
|
|
|
# TLS certificate is likely not issued for 127.0.0.1 so don't verify
|
|
|
|
|
r = requests.get(url, verify=False)
|
2022-10-22 20:00:13 -08:00
|
|
|
|
|
|
|
|
if r.status_code == 200:
|
2024-01-11 17:11:42 -06:00
|
|
|
sys.exit(0)
|
2022-10-22 20:00:13 -08:00
|
|
|
else:
|
2024-01-11 17:11:42 -06:00
|
|
|
sys.exit(1)
|
2022-10-22 20:00:13 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|