File size: 764 Bytes
8980653
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

def run_healthcheck():
    import os
    import requests
    import sys
    import structlog
    from samgis_core.utilities.session_logger import setup_logging

    log_level = os.getenv("LOG_LEVEL", "INFO")
    url1 = os.getenv("HEALTHCHECK_URL1", "http://localhost:7860/health")
    url2 = os.getenv("HEALTHCHECK_URL2", "http://localhost:7860/health_models")
    setup_logging(log_level=log_level)
    app_logger = structlog.stdlib.get_logger()

    r1 = requests.get(url1)
    app_logger.info(r1.status_code)
    r2 = requests.get(url2)
    app_logger.info(f"status health:{r1.status_code}, health_models:{r2.status_code}!")
    sys.exit(0) if r1.status_code == 200 and r2.status_code == 200 else sys.exit(1)


if __name__ == "__main__":
    run_healthcheck()