mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-08 06:31:58 +00:00
implemented workerN signal target
This commit is contained in:
@@ -43,6 +43,9 @@ cycle:
|
||||
uwsgi_error("read()");
|
||||
}
|
||||
else {
|
||||
if (uwsgi_signal_handler(received_signal)) {
|
||||
uwsgi_log_verbose("error managing signal %d on worker %d\n", received_signal, uwsgi.mywid);
|
||||
}
|
||||
wsgi_req->signal_received = received_signal;
|
||||
if (wait_for_specific_signal) {
|
||||
if (received_signal != uwsgi_signal) goto cycle;
|
||||
@@ -54,6 +57,9 @@ cycle:
|
||||
uwsgi_error("read()");
|
||||
}
|
||||
else {
|
||||
if (uwsgi_signal_handler(received_signal)) {
|
||||
uwsgi_log_verbose("error managing signal %d on worker %d\n", received_signal, uwsgi.mywid);
|
||||
}
|
||||
wsgi_req->signal_received = received_signal;
|
||||
if (wait_for_specific_signal) {
|
||||
if (received_signal != uwsgi_signal) goto cycle;
|
||||
|
||||
@@ -172,6 +172,17 @@ void uwsgi_route_signal(uint8_t sig) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// route to specific worker
|
||||
else if (!strncmp(use->receiver, "worker", 6)) {
|
||||
i = atoi(use->receiver+6);
|
||||
if (i > uwsgi.numproc) {
|
||||
uwsgi_log("invalid signal target: %s\n", use->receiver);
|
||||
}
|
||||
if (write(uwsgi.workers[i].signal_pipe[0], &sig, 1) != 1) {
|
||||
uwsgi_error("write()");
|
||||
uwsgi_log("could not deliver signal %d to worker %d\n", sig, i);
|
||||
}
|
||||
}
|
||||
// route to subscribed
|
||||
else if (!strcmp(use->receiver, "subscribed")) {
|
||||
}
|
||||
@@ -186,11 +197,6 @@ void uwsgi_route_signal(uint8_t sig) {
|
||||
}
|
||||
else {
|
||||
// unregistered signal, sending it to all the workers
|
||||
uwsgi_log("^^^ ROUTING UNREGISTERED SIGNAL ^^^\n");
|
||||
if (write(ushared->worker_signal_pipe[0], &sig, 1) != 1) {
|
||||
uwsgi_error("write()");
|
||||
uwsgi_log("could not deliver signal %d to workers pool\n", sig);
|
||||
}
|
||||
|
||||
uwsgi_log("^^^ UNSUPPORTED SIGNAL TARGET: %s ^^^\n", use->receiver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ from uwsgidecorators import *
|
||||
def hello(signum):
|
||||
print("I AM THE WORKER %d" % uwsgi.worker_id())
|
||||
|
||||
@signal(30, target='worker2')
|
||||
def hello2(signum):
|
||||
print("I AM THE WORKER 2")
|
||||
|
||||
@postfork
|
||||
def wait_for_signal():
|
||||
if uwsgi.worker_id() != 2:
|
||||
@@ -17,6 +21,7 @@ def application(e, s):
|
||||
s('200 OK', [('Content-Type', 'text/html')])
|
||||
if e['PATH_INFO'] == '/30':
|
||||
uwsgi.signal(30)
|
||||
uwsgi.signal(100)
|
||||
else:
|
||||
uwsgi.signal(17)
|
||||
return "Signal raised"
|
||||
|
||||
Reference in New Issue
Block a user