diff --git a/decoratortest.py b/decoratortest.py new file mode 100644 index 00000000..5fdcc9fa --- /dev/null +++ b/decoratortest.py @@ -0,0 +1,16 @@ +import uwsgi +from uwsgidecorators import * + +from uwsgicc import app as application + +import time + + +@rpc("helloworld") +def hello_world(): + return "Hello World" + +@signal(1) +def what_time_is_it(num): + print(time.asctime()) + diff --git a/master.c b/master.c index ba4f63e0..85831f28 100644 --- a/master.c +++ b/master.c @@ -693,7 +693,7 @@ void master_loop(char **argv, char **environ) { char byte; rlen = read(uwsgi.emperor_fd, &byte, 1); if (rlen > 0) { - uwsgi_log("received message %d from emperor\n", byte); + uwsgi_log_verbose("received message %d from emperor\n", byte); // remove me if (byte == 0) { close(uwsgi.emperor_fd); @@ -883,7 +883,7 @@ void master_loop(char **argv, char **environ) { uwsgi_error("read()"); } else if (rlen > 0) { - uwsgi_log("received uwsgi signal %d from workers\n", uwsgi_signal); + uwsgi_log_verbose("received uwsgi signal %d from a worker\n", uwsgi_signal); uwsgi_route_signal(uwsgi_signal); } else { diff --git a/plugins/python/uwsgi_pymodule.c b/plugins/python/uwsgi_pymodule.c index 19950648..201491f3 100644 --- a/plugins/python/uwsgi_pymodule.c +++ b/plugins/python/uwsgi_pymodule.c @@ -488,9 +488,11 @@ PyObject *py_uwsgi_signal(PyObject * self, PyObject * args) { return NULL; } +#ifdef UWSGI_DEBUG uwsgi_log("sending %d to master\n", uwsgi_signal); +#endif - rlen = write(uwsgi.shared->worker_signal_pipe[1], &uwsgi_signal, 1); + rlen = write(uwsgi.signal_socket, &uwsgi_signal, 1); if (rlen != 1) { uwsgi_error("write()"); } diff --git a/utils.c b/utils.c index f8ec4be6..12fed101 100644 --- a/utils.c +++ b/utils.c @@ -775,7 +775,9 @@ int wsgi_req_accept(struct wsgi_request *wsgi_req) { } } else { +#ifdef UWSGI_DEBUG uwsgi_log_verbose("master sent signal %d to worker %d\n", uwsgi_signal, uwsgi.mywid); +#endif if (uwsgi_signal_handler(uwsgi_signal)) { uwsgi_log_verbose("error managing signal %d on worker %d\n", uwsgi_signal, uwsgi.mywid); } diff --git a/uwsgicc/templates/index.html b/uwsgicc/templates/index.html index 008f9dbe..4a38c43c 100644 --- a/uwsgicc/templates/index.html +++ b/uwsgicc/templates/index.html @@ -174,7 +174,7 @@ $(document).ready(function() {

uWSGI {{uwsgi.version}} Control Center

-information | options | logs | workers | rpc {% if uwsgi.cluster() %}| cluster{% endif %} +information | options | logs | signals | workers | rpc {% if uwsgi.cluster() %}| cluster{% endif %}
{% with messages = get_flashed_messages() %} @@ -239,6 +239,21 @@ $(document).ready(function() { + +

Signals

+
+
+ + +
+ +
+ back to top +
+ +
+ +

Workers

diff --git a/uwsgicc/uwsgicc.py b/uwsgicc/uwsgicc.py index ca511148..af0303e2 100644 --- a/uwsgicc/uwsgicc.py +++ b/uwsgicc/uwsgicc.py @@ -23,6 +23,15 @@ def log(): flash("log message written") return redirect(url_for('index')) +@app.route("/sig", methods=['POST']) +def sig(): + try: + uwsgi.signal(int(request.form['signum'])) + flash("uwsgi signal sent") + except: + flash("unable to send signal") + return redirect(url_for('index')) + @app.route("/rpc", methods=['POST']) def rpc(): node = str(request.form['node']) diff --git a/uwsgidecorators.py b/uwsgidecorators.py new file mode 100644 index 00000000..561de52c --- /dev/null +++ b/uwsgidecorators.py @@ -0,0 +1,19 @@ +import uwsgi + +class rpc(object): + + def __init__(self, name): + self.name = name + + def __call__(self, f): + uwsgi.register_rpc(self.name, f) + return f + +class signal(object): + + def __init__(self, num): + self.num = num + + def __call__(self, f): + uwsgi.register_signal(self.num, "", f) + return f