From 4005614ced39886b2109d05e56ff53ca519ff31c Mon Sep 17 00:00:00 2001 From: benoitc Date: Sun, 23 May 2010 00:17:44 +0200 Subject: [PATCH] when_ready hook. Called just after the server is started --- gunicorn/arbiter.py | 2 +- gunicorn/config.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index f7ce1912e..ddf32f758 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -97,7 +97,7 @@ def start(self): self.pidfile.create(self.pid) self.log.info("Arbiter booted") self.log.info("Listening at: %s" % self.LISTENER) - + self.cfg.when_ready(self) def init_signals(self): """\ diff --git a/gunicorn/config.py b/gunicorn/config.py index aa306dc3d..6febbe241 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -536,3 +536,17 @@ def def_pre_exec(server): The callable needs to accept a single instance variable for the Arbiter. """) + + +with Setting("when_ready") as s: + s.section = "Server Hooks" + s.validator = validate_callable(1) + s.type = "callable" + def def_start_server(server): + pass + s.default = def_start_server + s.fmt_desc("""\ + Called just after the server is started + + The callable needs to accept a single instance variable for the Arbiter. + """)