status.py 605 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python3.9
  2. import os
  3. import signal
  4. PRO_PATH = "/platform/LAS/"
  5. PIDFILE = PRO_PATH + "LAS.pid"
  6. def is_running(pid):
  7. try:
  8. os.kill(pid, 0)
  9. return True
  10. except OSError:
  11. return False
  12. def status():
  13. if not os.path.exists(PIDFILE):
  14. print("LAS is NOT running (no PID file).")
  15. return
  16. with open(PIDFILE, "r") as f:
  17. pid = int(f.read())
  18. if is_running(pid):
  19. print(f"LAS is running with PID {pid}")
  20. else:
  21. print(f"LAS is NOT running (PID file found but process is gone).")
  22. if __name__ == "__main__":
  23. status()