diff --git a/master.c b/master.c index bb23c453..410d8b01 100644 --- a/master.c +++ b/master.c @@ -346,6 +346,13 @@ void master_loop(char **argv, char **environ) { } switch(uwsgi.wsgi_requests[0]->uh.modifier1) { + case 96: + uwsgi_log_verbose("%.*s", uwsgi.wsgi_requests[0]->uh.pktsize, uwsgi.wsgi_requests[0]->buffer); + case 98: + if (kill(getpid(), SIGHUP)) { + uwsgi_error("kill()"); + } + break; case 99: if (uwsgi.wsgi_requests[0]->uh.modifier2 == 0) { uwsgi_log("requested configuration data, sending %d bytes\n", cluster_opt_size); diff --git a/protocol.c b/protocol.c index c8eb653a..ebf8d28f 100644 --- a/protocol.c +++ b/protocol.c @@ -43,7 +43,7 @@ ssize_t send_udp_message(uint8_t modifier1, char *host, char *message, uint16_t memset(&udp_addr, 0, sizeof(struct sockaddr_in)); udp_addr.sin_family = AF_INET; - udp_addr.sin_port = htons(atoi(udp_port)); + udp_addr.sin_port = htons(atoi(udp_port+1)); udp_addr.sin_addr.s_addr = inet_addr(host); udpbuff[0] = modifier1; diff --git a/uwsgi.c b/uwsgi.c index 5267d237..4e5b6284 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -97,6 +97,8 @@ static struct option long_base_options[] = { {"multicast", required_argument, 0, LONG_ARGS_MULTICAST}, {"cluster", required_argument, 0, LONG_ARGS_CLUSTER}, #endif + {"cluster-reload", required_argument, 0, LONG_ARGS_CLUSTER_RELOAD}, + {"cluster-log", required_argument, 0, LONG_ARGS_CLUSTER_LOG}, #ifdef UWSGI_SNMP {"snmp", no_argument, 0, LONG_ARGS_SNMP}, {"snmp-community", required_argument, 0, LONG_ARGS_SNMP_COMMUNITY}, @@ -1496,6 +1498,12 @@ end: case 0: return 1; + case LONG_ARGS_CLUSTER_RELOAD: + send_udp_message(98, optarg, "", 0); + break; + case LONG_ARGS_CLUSTER_LOG: + uwsgi_stdin_sendto(optarg, 96, 0); + break; case LONG_ARGS_VHOSTHOST: uwsgi.vhost = 1; uwsgi.vhost_host = 1; @@ -2223,3 +2231,24 @@ int uwsgi_cluster_join(char *name) { return fd; } + +void uwsgi_stdin_sendto(char *socket_name, uint8_t modifier1, uint8_t modifier2) { + + char buf[4096]; + ssize_t rlen ; + size_t delta = 4096; + char *ptr = buf; + + rlen = read(0, ptr, delta); + while(rlen > 0) { + ptr += rlen; + delta-=rlen; + if (delta <= 0) break; + rlen = read(0, ptr, delta); + } + + if (ptr > buf) { + send_udp_message(modifier1, socket_name, ptr, ptr-buf); + } + +} diff --git a/uwsgi.h b/uwsgi.h index d7344d09..fe31ce07 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -242,6 +242,8 @@ struct uwsgi_opt { #define LONG_ARGS_UPLOAD_PROGRESS 17060 #define LONG_ARGS_REMAP_MODIFIER 17061 #define LONG_ARGS_CLUSTER 17062 +#define LONG_ARGS_CLUSTER_RELOAD 17063 +#define LONG_ARGS_CLUSTER_LOG 17064 @@ -1163,3 +1165,5 @@ int uwsgi_get_dgram(int, struct wsgi_request *); int uwsgi_cluster_join(char *); int uwsgi_string_sendto(int, uint8_t, uint8_t, struct sockaddr *, socklen_t, char *, size_t); + +void uwsgi_stdin_sendto(char *, uint8_t, uint8_t);