mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Some improvements to process control, should fix GH-112
This commit is contained in:
parent
938947d06c
commit
9c656ee90b
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
from setproctitle import setproctitle
|
from setproctitle import setproctitle
|
||||||
from ipaddress import ip_address
|
from ipaddress import ip_address
|
||||||
@ -40,9 +41,10 @@ def get_instance_supervisor():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def restart():
|
def restart():
|
||||||
stop()
|
if stop():
|
||||||
start()
|
start()
|
||||||
|
else:
|
||||||
|
print(col["red"]("Could not stop Maloja!"))
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
if get_instance_supervisor() is not None:
|
if get_instance_supervisor() is not None:
|
||||||
@ -69,16 +71,28 @@ def start():
|
|||||||
|
|
||||||
def stop():
|
def stop():
|
||||||
|
|
||||||
pid_sv = get_instance_supervisor()
|
for attempt in [(signal.SIGTERM,2),(signal.SIGTERM,5),(signal.SIGKILL,3),(signal.SIGKILL,5)]:
|
||||||
if pid_sv is not None:
|
|
||||||
os.kill(pid_sv,signal.SIGTERM)
|
pid_sv = get_instance_supervisor()
|
||||||
|
pid = get_instance()
|
||||||
|
|
||||||
|
if pid is None and pid_sv is None:
|
||||||
|
print("Maloja stopped!")
|
||||||
|
return True
|
||||||
|
|
||||||
|
if pid_sv is not None:
|
||||||
|
os.kill(pid_sv,attempt[0])
|
||||||
|
if pid is not None:
|
||||||
|
os.kill(pid,attempt[0])
|
||||||
|
|
||||||
|
time.sleep(attempt[1])
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pid = get_instance()
|
|
||||||
if pid is not None:
|
|
||||||
os.kill(pid,signal.SIGTERM)
|
|
||||||
|
|
||||||
if pid is None and pid_sv is None:
|
|
||||||
return False
|
|
||||||
|
|
||||||
print("Maloja stopped!")
|
print("Maloja stopped!")
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user