mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
better handling of QUIT/HUP soignal to fix issue #49. We want graceful
quit or restart if possible.
This commit is contained in:
parent
ba06498d7d
commit
2bc67cc8b8
@ -103,7 +103,6 @@ class Worker(object):
|
||||
|
||||
def handle_quit(self, sig, frame):
|
||||
self.alive = False
|
||||
os._exit(3)
|
||||
|
||||
def handle_exit(self, sig, frame):
|
||||
self.alive = False
|
||||
|
||||
@ -38,7 +38,7 @@ class EventletWorker(AsyncWorker):
|
||||
pool = greenpool.GreenPool(self.worker_connections)
|
||||
acceptor = greenthread.spawn(self.acceptor, pool)
|
||||
|
||||
while True:
|
||||
while self.alive:
|
||||
self.notify()
|
||||
|
||||
if self.ppid != os.getppid():
|
||||
@ -50,10 +50,11 @@ class EventletWorker(AsyncWorker):
|
||||
|
||||
with eventlet.Timeout(self.timeout, False):
|
||||
pool.waitall()
|
||||
os._exit(3)
|
||||
|
||||
def acceptor(self, pool):
|
||||
greenthread.getcurrent()
|
||||
while True:
|
||||
while self.alive:
|
||||
try:
|
||||
conn, addr = self.socket.accept()
|
||||
gt = pool.spawn(self.handle, conn, addr)
|
||||
|
||||
@ -35,7 +35,7 @@ class GEventWorker(AsyncWorker):
|
||||
acceptor = gevent.spawn(self.acceptor, pool)
|
||||
|
||||
try:
|
||||
while True:
|
||||
while self.alive:
|
||||
self.notify()
|
||||
|
||||
if self.ppid != os.getppid():
|
||||
@ -47,6 +47,7 @@ class GEventWorker(AsyncWorker):
|
||||
pool.join(timeout=self.timeout)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
os._exit(3)
|
||||
|
||||
def acceptor(self, pool):
|
||||
gevent.getcurrent()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user