From 471bd23acfdc971b2a600e044c19a63c6eb2649b Mon Sep 17 00:00:00 2001 From: "roberto@debian32" Date: Mon, 21 Nov 2011 20:22:00 +0100 Subject: [PATCH] added --subscribe-freq and --subscription-tolerance --- master.c | 4 ++-- plugins/fastrouter/fastrouter.c | 3 +++ subscription.c | 2 +- uwsgi.c | 12 ++++++++++++ uwsgi.h | 4 ++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/master.c b/master.c index edc06d7d..7a2ef296 100644 --- a/master.c +++ b/master.c @@ -1371,8 +1371,8 @@ healthy: uwsgi_cluster_add_me(); } - // resubscribe every 10 cycles - if (uwsgi.subscriptions && ((uwsgi.master_cycles % 10) == 0 || uwsgi.master_cycles == 1)) { + // resubscribe every 10 cycles by default + if (uwsgi.subscriptions && ((uwsgi.master_cycles % uwsgi.subscribe_freq) == 0 || uwsgi.master_cycles == 1)) { struct uwsgi_string_list *subscriptions = uwsgi.subscriptions; while(subscriptions) { uwsgi_subscribe(subscriptions->value, 0); diff --git a/plugins/fastrouter/fastrouter.c b/plugins/fastrouter/fastrouter.c index 2acd4d50..dc96a574 100644 --- a/plugins/fastrouter/fastrouter.c +++ b/plugins/fastrouter/fastrouter.c @@ -20,6 +20,7 @@ #define LONG_ARGS_FASTROUTER_TIMEOUT 150006 #define LONG_ARGS_FASTROUTER_SUBSCRIPTION_SLOT 150007 #define LONG_ARGS_FASTROUTER_USE_CODE_STRING 150008 +#define LONG_ARGS_FASTROUTER_TOLERANCE 150009 #define FASTROUTER_STATUS_FREE 0 #define FASTROUTER_STATUS_CONNECTING 1 @@ -71,6 +72,8 @@ struct uwsgi_fastrouter { int cheap; int i_am_cheap; + + int tolerance; } ufr; static void fastrouter_go_cheap(void) { diff --git a/subscription.c b/subscription.c index 4f9df0e7..0625f6af 100644 --- a/subscription.c +++ b/subscription.c @@ -80,7 +80,7 @@ struct uwsgi_subscribe_node *uwsgi_get_subscribe_node(struct uwsgi_subscribe_slo struct uwsgi_subscribe_node *node = current_slot->nodes; while(current_slot && node) { // is the node alive ? - if (current - node->last_check > 10) { + if (current - node->last_check > uwsgi.subscription_tolerance) { node->death_mark = 1; } if (node->death_mark && node->reference == 0) { diff --git a/uwsgi.c b/uwsgi.c index acabf185..4d79119e 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -204,6 +204,9 @@ static struct option long_base_options[] = { {"cluster-log", required_argument, 0, LONG_ARGS_CLUSTER_LOG}, #endif {"subscribe-to", required_argument, 0, LONG_ARGS_SUBSCRIBE_TO}, + {"subscribe", required_argument, 0, LONG_ARGS_SUBSCRIBE_TO}, + {"subscribe-freq", required_argument, 0, LONG_ARGS_SUBSCRIBE_FREQ}, + {"subscription-tolerance", required_argument, 0, LONG_ARGS_SUBSCR_TOLERANCE}, #ifdef UWSGI_SNMP {"snmp", optional_argument, 0, LONG_ARGS_SNMP}, {"snmp-community", required_argument, 0, LONG_ARGS_SNMP_COMMUNITY}, @@ -1072,6 +1075,9 @@ int main(int argc, char *argv[], char *envp[]) { uwsgi.emperor_throttle = 1000; uwsgi.emperor_pid = -1; + uwsgi.subscribe_freq = 10; + uwsgi.subscription_tolerance = 17; + uwsgi.cluster_fd = -1; uwsgi.cores = 1; @@ -3397,6 +3403,12 @@ static int manage_base_opt(int i, char *optarg) { uwsgi.master_process = 1; uwsgi_string_new_list(&uwsgi.subscriptions, optarg); return 1; + case LONG_ARGS_SUBSCR_TOLERANCE: + uwsgi.subscription_tolerance = atoi(optarg); + return 1; + case LONG_ARGS_SUBSCRIBE_FREQ: + uwsgi.subscribe_freq = atoi(optarg); + return 1; #ifdef __linux__ case LONG_ARGS_CGROUP: uwsgi_string_new_list(&uwsgi.cgroup, optarg); diff --git a/uwsgi.h b/uwsgi.h index d66c47b2..907e61c9 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -543,6 +543,8 @@ struct uwsgi_opt { #define LONG_ARGS_SIGNAL 17163 #define LONG_ARGS_KSM 17164 #define LONG_ARGS_LOGFILE_CHMOD 17165 +#define LONG_ARGS_SUBSCRIBE_FREQ 17166 +#define LONG_ARGS_SUBSCR_TOLERANCE 17167 #define UWSGI_OK 0 @@ -1527,6 +1529,8 @@ struct uwsgi_server { int startup_daemons_cnt; // subscription client + int subscribe_freq; + int subscription_tolerance; struct uwsgi_string_list *subscriptions; #ifdef __linux__