Browse Source

[Update] 修改jms

pull/3446/head
ibuler 5 years ago
parent
commit
d563a11acf
  1. 16
      jms

16
jms

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

Loading…
Cancel
Save