mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-05 13:11:33 +00:00
greatly improved chain reload in gevent mode
This commit is contained in:
+3
-4
@@ -170,10 +170,9 @@ void uwsgi_master_check_mercy() {
|
||||
for (i = 1; i <= uwsgi.numproc; i++) {
|
||||
if (uwsgi.workers[i].pid > 0 && uwsgi.workers[i].cursed_at) {
|
||||
if (uwsgi_now() > uwsgi.workers[i].no_mercy_at) {
|
||||
uwsgi_log("worker %d (pid: %d) is taking too much time to die...NO MERCY !!!\n", i, uwsgi.workers[i].pid);
|
||||
if (kill(uwsgi.workers[i].pid, SIGKILL)) {
|
||||
uwsgi_error("uwsgi_master_check_mercy()/kill()");
|
||||
}
|
||||
uwsgi_log_verbose("worker %d (pid: %d) is taking too much time to die...NO MERCY !!!\n", i, uwsgi.workers[i].pid);
|
||||
// yes that look strangem but we avoid callign it again if we skip waitpid() call below
|
||||
uwsgi_curse(i, SIGKILL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,6 +586,7 @@ int uwsgi_respawn_worker(int wid) {
|
||||
|
||||
// reset wsgi_request structures
|
||||
for(i=0;i<uwsgi.cores;i++) {
|
||||
uwsgi.workers[uwsgi.mywid].cores[i].in_request = 0;
|
||||
memset(&uwsgi.workers[uwsgi.mywid].cores[i].req, 0, sizeof(struct wsgi_request));
|
||||
}
|
||||
|
||||
|
||||
@@ -697,6 +697,9 @@ void uwsgi_close_request(struct wsgi_request *wsgi_req) {
|
||||
memset(wsgi_req, 0, sizeof(struct wsgi_request));
|
||||
wsgi_req->async_id = tmp_id;
|
||||
|
||||
// yes, this is pretty useless but we cannot ensure all of the plugin have the same behaviour
|
||||
uwsgi.workers[uwsgi.mywid].cores[wsgi_req->async_id].in_request = 0;
|
||||
|
||||
if (uwsgi.shared->options[UWSGI_OPTION_MAX_REQUESTS] > 0
|
||||
&& uwsgi.workers[uwsgi.mywid].delta_requests >= uwsgi.shared->options[UWSGI_OPTION_MAX_REQUESTS]
|
||||
&& (end_of_request - (uwsgi.workers[uwsgi.mywid].last_spawn*1000000) >= uwsgi.shared->options[UWSGI_OPTION_MIN_WORKER_LIFETIME]*1000000)) {
|
||||
|
||||
+10
-4
@@ -29,26 +29,30 @@ PyObject *py_uwsgi_gevent_graceful(PyObject *self, PyObject *args) {
|
||||
uwsgi_log("Gracefully killing worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid);
|
||||
uwsgi.workers[uwsgi.mywid].manage_next_request = 0;
|
||||
|
||||
uwsgi_log("stopping gevent signals watchers for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid);
|
||||
uwsgi_log_verbose("stopping gevent signals watchers for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid);
|
||||
PyObject_CallMethod(ugevent.my_signal_watcher, "stop", NULL);
|
||||
PyObject_CallMethod(ugevent.signal_watcher, "stop", NULL);
|
||||
|
||||
uwsgi_log("stopping gevent sockets watchers for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid);
|
||||
uwsgi_log_verbose("stopping gevent sockets watchers for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid);
|
||||
int i,count = uwsgi_count_sockets(uwsgi.sockets);
|
||||
for(i=0;i<count;i++) {
|
||||
PyObject_CallMethod(ugevent.watchers[i], "stop", NULL);
|
||||
}
|
||||
uwsgi_log("main gevent watchers stopped for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid);
|
||||
uwsgi_log_verbose("main gevent watchers stopped for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid);
|
||||
|
||||
int running_cores = 0;
|
||||
for(i=0;i<uwsgi.async;i++) {
|
||||
if (uwsgi.workers[uwsgi.mywid].cores[i].in_request) {
|
||||
struct wsgi_request *wsgi_req = &uwsgi.workers[uwsgi.mywid].cores[i].req;
|
||||
uwsgi_log_verbose("worker %d (pid: %d) core %d is managing \"%.*s %.*s\" for %.*s\n", uwsgi.mywid, uwsgi.mypid, i,
|
||||
wsgi_req->method_len, wsgi_req->method, wsgi_req->uri_len, wsgi_req->uri,
|
||||
wsgi_req->remote_addr_len, wsgi_req->remote_addr);
|
||||
running_cores++;
|
||||
}
|
||||
}
|
||||
|
||||
if (running_cores > 0) {
|
||||
uwsgi_log("waiting for %d running requests...\n", running_cores);
|
||||
uwsgi_log_verbose("waiting for %d running requests...\n", running_cores);
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
@@ -162,6 +166,8 @@ edge:
|
||||
if (uwsgi_sock->retry && uwsgi_sock->retry[wsgi_req->async_id]) {
|
||||
goto edge;
|
||||
}
|
||||
// in case of errors (or thundering herd, just rest it)
|
||||
uwsgi.workers[uwsgi.mywid].cores[wsgi_req->async_id].in_request = 0;
|
||||
goto clear;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user