stop.py 538 B

1234567891011121314151617181920212223242526
  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 stop():
  7. if not os.path.exists(PIDFILE):
  8. print("No PID file found. Is LAS running?")
  9. return
  10. with open(PIDFILE, "r") as f:
  11. pid = int(f.read())
  12. try:
  13. os.kill(pid, signal.SIGTERM)
  14. print(f"Stopped LAS (PID {pid})")
  15. except ProcessLookupError:
  16. print(f"No process found with PID {pid}")
  17. finally:
  18. os.remove(PIDFILE)
  19. if __name__ == "__main__":
  20. stop()