2019-09-02 02:22:17 +03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import time
|
|
|
|
import setproctitle
|
|
|
|
import signal
|
2019-10-16 16:09:15 +03:00
|
|
|
from doreah.logging import log
|
2019-09-02 02:22:17 +03:00
|
|
|
|
|
|
|
|
|
|
|
setproctitle.setproctitle("maloja_supervisor")
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
time.sleep(60)
|
|
|
|
|
|
|
|
try:
|
|
|
|
output = subprocess.check_output(["pidof","Maloja"])
|
|
|
|
pid = int(output)
|
2019-10-16 16:09:15 +03:00
|
|
|
log("Maloja is running, PID " + str(pid),module="supervisor")
|
2019-09-02 02:22:17 +03:00
|
|
|
except:
|
2019-10-16 16:09:15 +03:00
|
|
|
log("Maloja is not running, restarting...",module="supervisor")
|
|
|
|
try:
|
|
|
|
p = subprocess.Popen(["python3","server.py"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
|
|
|
except e:
|
|
|
|
log("Error starting Maloja: " + str(e),module="supervisor")
|