From 4da4fb4cbdfc0494c305bce3ca22431053d216ae Mon Sep 17 00:00:00 2001 From: "roberto@precise64" Date: Sun, 26 Feb 2012 12:30:35 +0100 Subject: [PATCH] completed clustering porting --- utils.c | 4 ++++ uwsgi.c | 14 +++++++++++--- uwsgi.h | 3 +++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/utils.c b/utils.c index fac54401..261391b0 100644 --- a/utils.c +++ b/utils.c @@ -2016,6 +2016,10 @@ add: if (op->flags & UWSGI_OPT_NO_SERVER) { uwsgi.no_server = 1; } + // requires cluster ? + if (op->flags & UWSGI_OPT_CLUSTER) { + uwsgi.cluster = value; + } // requires post_buffering ? if (op->flags & UWSGI_OPT_POST_BUFFERING) { if (!uwsgi.post_buffering) uwsgi.post_buffering = 4096; diff --git a/uwsgi.c b/uwsgi.c index cfd43e2e..9d3f3a72 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -248,9 +248,9 @@ static struct uwsgi_option uwsgi_base_options[] = { #ifdef UWSGI_MULTICAST {"multicast", required_argument, 0, "subscribe to specified multicast group", uwsgi_opt_set_str, &uwsgi.multicast_group, UWSGI_OPT_MASTER}, {"cluster", required_argument, 0, "join specified uWSGI cluster", uwsgi_opt_set_str, &uwsgi.cluster, UWSGI_OPT_MASTER}, - //{"cluster-nodes", required_argument, 0, LONG_ARGS_CLUSTER_NODES,0}, - //{"cluster-reload", required_argument, 0, LONG_ARGS_CLUSTER_RELOAD,0}, - //{"cluster-log", required_argument, 0, LONG_ARGS_CLUSTER_LOG,0}, + {"cluster-nodes", required_argument, 0, "get nodes list from the specified cluster", uwsgi_opt_true, &uwsgi.cluster_nodes, UWSGI_OPT_MASTER|UWSGI_OPT_CLUSTER}, + {"cluster-reload", required_argument, 0, "send a reload message to the cluster", uwsgi_opt_cluster_reload, NULL, 0}, + {"cluster-log", required_argument, 0, "send a log line to the cluster", uwsgi_opt_cluster_log, NULL, 0}, #endif {"subscribe-to", required_argument, 0, "subscribe to the specified subscription server", uwsgi_opt_add_string_list, &uwsgi.subscriptions, UWSGI_OPT_MASTER}, {"st", required_argument, 0, "subscribe to the specified subscription server", uwsgi_opt_add_string_list, &uwsgi.subscriptions, UWSGI_OPT_MASTER}, @@ -3311,6 +3311,14 @@ void uwsgi_opt_true(char *opt, char *value, void *key) { } } +void uwsgi_opt_cluster_reload(char *opt, char *value, void *foobar) { + send_udp_message(98, 0, value, NULL, 0); +} + +void uwsgi_opt_cluster_log(char *opt, char *value, void *foobar) { + uwsgi_stdin_sendto(value, 96, 0); +} + void uwsgi_opt_set_int(char *opt, char *value, void *key) { int *ptr = (int *) key; if (value) { diff --git a/uwsgi.h b/uwsgi.h index f60731a8..5bc83fa2 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -49,6 +49,7 @@ extern "C" { #define UWSGI_OPT_NO_INITIAL (1 << 9) #define UWSGI_OPT_NO_SERVER (1 << 10) #define UWSGI_OPT_POST_BUFFERING (1 << 11) +#define UWSGI_OPT_CLUSTER (1 << 12) #define MAX_APPS 64 #define MAX_GENERIC_PLUGINS 64 @@ -2568,6 +2569,8 @@ void uwsgi_opt_add_socket(char *, char *, void *); void uwsgi_opt_add_cron(char *, char *, void *); void uwsgi_opt_load_plugin(char *, char *, void *); void uwsgi_opt_load(char *, char *, void *); +void uwsgi_opt_cluster_log(char *, char *, void *); +void uwsgi_opt_cluster_reload(char *, char *, void *); #ifdef UWSGI_INI void uwsgi_opt_load_ini(char *, char *, void *); #endif