From 0dc8803ff8df1401ec5f4bcf890a14d3d8fde585 Mon Sep 17 00:00:00 2001 From: Unbit Date: Fri, 26 Jul 2013 12:03:38 +0200 Subject: [PATCH] added --force-gateway --- core/gateway.c | 2 +- core/uwsgi.c | 6 ++++++ uwsgi.h | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/gateway.c b/core/gateway.c index 86b8105f..15b08b12 100644 --- a/core/gateway.c +++ b/core/gateway.c @@ -41,7 +41,7 @@ struct uwsgi_gateway *register_gateway(char *name, void (*loop) (int, void *), v uwsgi_socket_nb(ug->internal_subscription_pipe[0]); uwsgi_socket_nb(ug->internal_subscription_pipe[1]); - if (!uwsgi.master_process) + if (!uwsgi.master_process && !uwsgi.force_gateway) gateway_respawn(ushared->gateways_cnt); ushared->gateways_cnt++; diff --git a/core/uwsgi.c b/core/uwsgi.c index 2abbd6d5..e3113aa5 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -206,6 +206,7 @@ static struct uwsgi_option uwsgi_base_options[] = { {"worker-reload-mercy", required_argument, 0, "set the maximum time (in seconds) a worker can take to reload/shutdown (default is 60)", uwsgi_opt_set_int, &uwsgi.worker_reload_mercy, 0}, {"exit-on-reload", no_argument, 0, "force exit even if a reload is requested", uwsgi_opt_true, &uwsgi.exit_on_reload, 0}, {"die-on-term", no_argument, 0, "exit instead of brutal reload on SIGTERM", uwsgi_opt_true, &uwsgi.die_on_term, 0}, + {"force-gateway", no_argument, 0, "force teh spawn of the first registered gateway without a master", uwsgi_opt_true, &uwsgi.force_gateway, 0}, {"help", no_argument, 'h', "show this help", uwsgi_help, NULL, UWSGI_OPT_IMMEDIATE}, {"usage", no_argument, 'h', "show this help", uwsgi_help, NULL, UWSGI_OPT_IMMEDIATE}, @@ -2469,6 +2470,11 @@ int uwsgi_start(void *v_argv) { else if (!uwsgi.sockets && ushared->gateways_cnt && !uwsgi.no_server && !uwsgi.master_process) { // here we will have a zombie... sorry uwsgi_log("...you should enable the master process... really...\n"); + if (uwsgi.force_gateway) { + struct uwsgi_gateway *ug = &ushared->gateways[0]; + ug->loop(0, ug->data); + // when we are here the gateway is dead :( + } exit(0); } diff --git a/uwsgi.h b/uwsgi.h index 2163f809..a0e0abde 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -1640,6 +1640,9 @@ struct uwsgi_server { // kill the stack on SIGTERM (instead of brutal reloading) int die_on_term; + // force the first gateway without a master + int force_gateway; + // disable fd passing on unix socket int no_fd_passing;