|
|
|
@ -114,7 +114,7 @@ def check_pid(pid):
|
|
|
|
|
""" Check For the existence of a unix pid. """
|
|
|
|
|
try:
|
|
|
|
|
os.kill(pid, 0)
|
|
|
|
|
except OSError:
|
|
|
|
|
except (OSError, ProcessLookupError):
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
return True
|
|
|
|
@ -231,6 +231,9 @@ def get_start_worker_kwargs(queue, num):
|
|
|
|
|
|
|
|
|
|
if os.getuid() == 0:
|
|
|
|
|
os.environ.setdefault('C_FORCE_ROOT', '1')
|
|
|
|
|
server_hostname = os.environ.get("SERVER_HOSTNAME")
|
|
|
|
|
if not server_hostname:
|
|
|
|
|
server_hostname = '%h'
|
|
|
|
|
|
|
|
|
|
cmd = [
|
|
|
|
|
'celery', 'worker',
|
|
|
|
@ -238,7 +241,7 @@ def get_start_worker_kwargs(queue, num):
|
|
|
|
|
'-l', 'INFO',
|
|
|
|
|
'-c', str(num),
|
|
|
|
|
'-Q', queue,
|
|
|
|
|
'-n', '{}@%h'.format(queue)
|
|
|
|
|
'-n', '{}@{}'.format(queue, server_hostname)
|
|
|
|
|
]
|
|
|
|
|
return {"cmd": cmd, "cwd": APPS_DIR}
|
|
|
|
|
|
|
|
|
@ -437,6 +440,12 @@ def stop_service(srv, sig=15):
|
|
|
|
|
print("Stop service: {}".format(s), end='')
|
|
|
|
|
pid = get_pid(s)
|
|
|
|
|
os.kill(pid, sig)
|
|
|
|
|
with LOCK:
|
|
|
|
|
process = processes.pop(s, None)
|
|
|
|
|
if process is None:
|
|
|
|
|
print("\033[31m No process found\033[0m")
|
|
|
|
|
continue
|
|
|
|
|
process.wait(1)
|
|
|
|
|
for i in range(STOP_TIMEOUT):
|
|
|
|
|
if i == STOP_TIMEOUT - 1:
|
|
|
|
|
print("\033[31m Error\033[0m")
|
|
|
|
@ -447,9 +456,6 @@ def stop_service(srv, sig=15):
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
with LOCK:
|
|
|
|
|
processes.pop(s, None)
|
|
|
|
|
|
|
|
|
|
if srv == "all":
|
|
|
|
|
stop_daemon_service()
|
|
|
|
|
|
|
|
|
|