mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Merge pull request #555 from seatgeek/post-init
Add post-init hook for workers
This commit is contained in:
commit
cee5c57abc
@ -561,6 +561,19 @@ Called just after a worker has been forked.
|
||||
The callable needs to accept two instance variables for the Arbiter and
|
||||
new Worker.
|
||||
|
||||
post_init
|
||||
~~~~~~~~~
|
||||
|
||||
* ::
|
||||
|
||||
def post_init(worker):
|
||||
pass
|
||||
|
||||
Called just after a worker has initialized the application.
|
||||
|
||||
The callable needs to accept one instance variable for the initialized
|
||||
Worker.
|
||||
|
||||
pre_exec
|
||||
~~~~~~~~
|
||||
|
||||
|
||||
@ -1162,6 +1162,24 @@ class Postfork(Setting):
|
||||
"""
|
||||
|
||||
|
||||
class PostInit(Setting):
|
||||
name = "post_init"
|
||||
section = "Server Hooks"
|
||||
validator = validate_callable(1)
|
||||
type = six.callable
|
||||
|
||||
def post_init(worker):
|
||||
pass
|
||||
|
||||
default = staticmethod(post_init)
|
||||
desc = """\
|
||||
Called just after a worker has initialized the application.
|
||||
|
||||
The callable needs to accept one instance variable for the initialized
|
||||
Worker.
|
||||
"""
|
||||
|
||||
|
||||
class PreExec(Setting):
|
||||
name = "pre_exec"
|
||||
section = "Server Hooks"
|
||||
|
||||
@ -99,6 +99,8 @@ class Worker(object):
|
||||
|
||||
self.wsgi = self.app.wsgi()
|
||||
|
||||
self.cfg.post_init(self)
|
||||
|
||||
# Enter main run loop
|
||||
self.booted = True
|
||||
self.run()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user