mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
add server hook "on_starting" to allow socket patching to allow gevent worker reloading.
This commit is contained in:
parent
974698671a
commit
06987d3702
@ -3,6 +3,11 @@ import os
|
||||
import signal
|
||||
import sys
|
||||
|
||||
def on_starting(server):
|
||||
# use server hook to patch socket to allow worker reloading
|
||||
from gevent import monkey
|
||||
monkey.patch_socket()
|
||||
|
||||
def when_ready(server):
|
||||
def monitor():
|
||||
modify_times = {}
|
||||
|
||||
@ -109,6 +109,7 @@ class Arbiter(object):
|
||||
"""\
|
||||
Initialize the arbiter. Start listening and set pidfile if needed.
|
||||
"""
|
||||
self.cfg.on_starting(self)
|
||||
self.pid = os.getpid()
|
||||
self.init_signals()
|
||||
if not self.LISTENER:
|
||||
|
||||
@ -703,3 +703,19 @@ class WorkerExit(Setting):
|
||||
The callable needs to accept two instance variables for the Arbiter and
|
||||
the just-exited Worker.
|
||||
"""
|
||||
|
||||
class OnStarting(Setting):
|
||||
name = "on_starting"
|
||||
section = "Server Hooks"
|
||||
validator = validate_callable(1)
|
||||
type = "callable"
|
||||
def def_on_starting(server):
|
||||
pass
|
||||
def_on_starting = staticmethod(def_on_starting)
|
||||
default = def_on_starting
|
||||
desc = """\
|
||||
Called just before the master process is initialized.
|
||||
|
||||
The callable needs to accept a single instance variable for the Arbiter.
|
||||
"""
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user