From e904f9f76ecc3fa5019d958ef22294e569fc3884 Mon Sep 17 00:00:00 2001 From: "roberto@quantal64" Date: Mon, 27 Aug 2012 17:52:56 +0200 Subject: [PATCH] improved gevent graceful reload --- core/uwsgi.c | 4 ++++ plugins/gevent/gevent.c | 8 ++++++-- plugins/python/python_plugin.c | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/uwsgi.c b/core/uwsgi.c index 0b71c0c1..ab41ecc6 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -1471,6 +1471,7 @@ static void cheaper_algo_list(void) { uwsgi_log("--- end of cheaper algorithms list ---\n\n"); } +#ifdef UWSGI_ROUTING static void router_list(void) { struct uwsgi_router *ur = uwsgi.routers; uwsgi_log("\n*** uWSGI loaded routers ***\n"); @@ -1480,6 +1481,7 @@ static void router_list(void) { } uwsgi_log("--- end of routers list ---\n\n"); } +#endif static void loop_list(void) { int i; @@ -1994,8 +1996,10 @@ int main(int argc, char *argv[], char *envp[]) { cheaper_algo_list(); +#ifdef UWSGI_ROUTING if (uwsgi.router_list) router_list(); +#endif if (uwsgi.loop_list) diff --git a/plugins/gevent/gevent.c b/plugins/gevent/gevent.c index 97ff5065..fa7e2d93 100644 --- a/plugins/gevent/gevent.c +++ b/plugins/gevent/gevent.c @@ -47,8 +47,6 @@ struct uwsgi_option gevent_options[] = { PyObject *py_uwsgi_gevent_graceful(PyObject *self, PyObject *args) { - uwsgi_log("%p %p\n", self, args); - uwsgi_log("Gracefully killing worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid); uwsgi.workers[uwsgi.mywid].manage_next_request = 0; @@ -63,6 +61,10 @@ PyObject *py_uwsgi_gevent_graceful(PyObject *self, PyObject *args) { } uwsgi_log("main gevent watchers stopped for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid); + if (args) { + exit(UWSGI_RELOAD_CODE); + } + Py_INCREF(Py_None); return Py_None; } @@ -73,6 +75,8 @@ void uwsgi_gevent_gbcw() { py_uwsgi_gevent_graceful(NULL, NULL); + exit(0); + } struct wsgi_request *uwsgi_gevent_current_wsgi_req(void) { diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 0d74c4c2..929e48be 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -526,7 +526,9 @@ next: +#ifdef UWSGI_EMBEDDED PyDoc_STRVAR(uwsgi_py_doc, "uWSGI api module."); +#endif #ifdef PYTHREE