mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
add on_exit hook
This commit is contained in:
parent
86bab94c6c
commit
9ade14ae78
@ -782,6 +782,17 @@ two integers of number of workers after and before change.
|
||||
If the number of workers is set for the first time, old_value would be
|
||||
None.
|
||||
|
||||
on_exit
|
||||
~~~~~~~
|
||||
* ::
|
||||
|
||||
def on_exit():
|
||||
pass
|
||||
|
||||
Called just before exiting gunicorn.
|
||||
|
||||
The callable needs to accept a single instance variable for the Arbiter.
|
||||
|
||||
Server Mechanics
|
||||
----------------
|
||||
|
||||
|
||||
@ -296,6 +296,7 @@ class Arbiter(object):
|
||||
self.log.info("Reason: %s", reason)
|
||||
if self.pidfile is not None:
|
||||
self.pidfile.unlink()
|
||||
self.cfg.on_exit(self)
|
||||
sys.exit(exit_status)
|
||||
|
||||
def sleep(self):
|
||||
|
||||
@ -1422,6 +1422,21 @@ class NumWorkersChanged(Setting):
|
||||
None.
|
||||
"""
|
||||
|
||||
class OnExit(Setting):
|
||||
name = "on_exit"
|
||||
section = "Server Hooks"
|
||||
validator = validate_callable(1)
|
||||
|
||||
def on_exit(server):
|
||||
pass
|
||||
|
||||
default = staticmethod(on_exit)
|
||||
desc = """\
|
||||
Called just before exiting gunicorn.
|
||||
|
||||
The callable needs to accept a single instance variable for the Arbiter.
|
||||
"""
|
||||
|
||||
|
||||
class ProxyProtocol(Setting):
|
||||
name = "proxy_protocol"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user