From fff5fa536bdc4426fcf188fc6d6d6f4afdf471e9 Mon Sep 17 00:00:00 2001 From: Unbit Date: Fri, 2 May 2014 07:14:05 +0200 Subject: [PATCH] allow fast moving to/from on_demand mode --- core/emperor.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/emperor.c b/core/emperor.c index 74315abc..99b67b6d 100644 --- a/core/emperor.c +++ b/core/emperor.c @@ -2240,6 +2240,19 @@ void uwsgi_emperor_simple_do(struct uwsgi_emperor_scanner *ues, char *name, char } // check if mtime is changed and the uWSGI instance must be reloaded if (ts > ui_current->last_mod) { + // now we neeed a special check for allowing an instance to move to "on_demand" mode (and back) + // allowing means "stoppping the instance" + if ((!ui_current->socket_name && ui_current->on_demand_fd == -1) && socket_name) { + uwsgi_log("[uwsgi-emperor] %s -> requested move to \"on demand\" mode for socket \"%s\" ...\n", name, socket_name); + emperor_stop(ui_current); + return; + } + else if ((ui_current->socket_name && ui_current->on_demand_fd > -1) && !socket_name) { + uwsgi_log("[uwsgi-emperor] %s -> asked for leaving \"on demand\" mode for socket \"%s\" ...\n", name, socket_name); + emperor_stop(ui_current); + return; + } + // make a new config (free the old one) if needed if (config) { if (ui_current->config)