#!/usr/bin/env python3 import time, urllib.request, subprocess, os BASE_DIR = "/workspace/personal/dashboards/VPN_chanel" RUN_SCRIPT = os.path.join(BASE_DIR, "run_services.sh") def check_service(url): try: with urllib.request.urlopen(url, timeout=3) as resp: return resp.status in (200, 404) except Exception: return False def main(): while True: fe_ok = check_service("http://127.0.0.1:3000/") be_ok = check_service("http://127.0.0.1:8000/api/v1/stats") if not (fe_ok and be_ok): subprocess.run(["bash", RUN_SCRIPT], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) time.sleep(30) if __name__ == "__main__": main()