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):
|
def handle_quit(self, sig, frame):
|
||||||
self.alive = False
|
self.alive = False
|
||||||
os._exit(3)
|
|
||||||
|
|
||||||
def handle_exit(self, sig, frame):
|
def handle_exit(self, sig, frame):
|
||||||
self.alive = False
|
self.alive = False
|
||||||
|
|||||||
@ -38,7 +38,7 @@ class EventletWorker(AsyncWorker):
|
|||||||
pool = greenpool.GreenPool(self.worker_connections)
|
pool = greenpool.GreenPool(self.worker_connections)
|
||||||
acceptor = greenthread.spawn(self.acceptor, pool)
|
acceptor = greenthread.spawn(self.acceptor, pool)
|
||||||
|
|
||||||
while True:
|
while self.alive:
|
||||||
self.notify()
|
self.notify()
|
||||||
|
|
||||||
if self.ppid != os.getppid():
|
if self.ppid != os.getppid():
|
||||||
@ -50,10 +50,11 @@ class EventletWorker(AsyncWorker):
|
|||||||
|
|
||||||
with eventlet.Timeout(self.timeout, False):
|
with eventlet.Timeout(self.timeout, False):
|
||||||
pool.waitall()
|
pool.waitall()
|
||||||
|
os._exit(3)
|
||||||
|
|
||||||
def acceptor(self, pool):
|
def acceptor(self, pool):
|
||||||
greenthread.getcurrent()
|
greenthread.getcurrent()
|
||||||
while True:
|
while self.alive:
|
||||||
try:
|
try:
|
||||||
conn, addr = self.socket.accept()
|
conn, addr = self.socket.accept()
|
||||||
gt = pool.spawn(self.handle, conn, addr)
|
gt = pool.spawn(self.handle, conn, addr)
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class GEventWorker(AsyncWorker):
|
|||||||
acceptor = gevent.spawn(self.acceptor, pool)
|
acceptor = gevent.spawn(self.acceptor, pool)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while self.alive:
|
||||||
self.notify()
|
self.notify()
|
||||||
|
|
||||||
if self.ppid != os.getppid():
|
if self.ppid != os.getppid():
|
||||||
@ -47,6 +47,7 @@ class GEventWorker(AsyncWorker):
|
|||||||
pool.join(timeout=self.timeout)
|
pool.join(timeout=self.timeout)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
os._exit(3)
|
||||||
|
|
||||||
def acceptor(self, pool):
|
def acceptor(self, pool):
|
||||||
gevent.getcurrent()
|
gevent.getcurrent()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user