mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-07 14:11:46 +00:00
--proxy-node @self
This commit is contained in:
@@ -80,9 +80,15 @@ void *uwsgi_request_subhandler_wsgi(struct wsgi_request *wsgi_req, struct uwsgi_
|
||||
|
||||
//PyDict_SetItemString(uwsgi.embedded_dict, "env", wsgi_req->async_environ);
|
||||
|
||||
//PyDict_SetItemString(wsgi_req->async_environ, "uwsgi.version", uwsgi_version);
|
||||
PyDict_SetItemString(wsgi_req->async_environ, "uwsgi.version", PyString_FromString(UWSGI_VERSION));
|
||||
if (uwsgi.cores > 1) {
|
||||
PyDict_SetItemString(wsgi_req->async_environ, "uwsgi.core", PyInt_FromLong(wsgi_req->async_id));
|
||||
}
|
||||
|
||||
PyDict_SetItemString(wsgi_req->async_environ, "uwsgi.core", PyInt_FromLong(wsgi_req->async_id));
|
||||
if (uwsgi.cluster_fd >= 0) {
|
||||
PyDict_SetItemString(wsgi_req->async_environ, "uwsgi.cluster", PyString_FromString(uwsgi.cluster));
|
||||
PyDict_SetItemString(wsgi_req->async_environ, "uwsgi.cluster_node", PyString_FromString(uwsgi.hostname));
|
||||
}
|
||||
|
||||
|
||||
#ifdef UWSGI_ROUTING
|
||||
|
||||
@@ -319,8 +319,8 @@ char *generate_socket_name(char *socket_name) {
|
||||
if (inet_ntop(AF_INET, (void *) &sin->sin_addr.s_addr, new_addr, 16)) {
|
||||
if (!strncmp( socket_name, new_addr, strlen(socket_name)) ) {
|
||||
asterisk[0] = '*';
|
||||
uwsgi_log("found %s for %s on interface %s\n", new_addr, socket_name, ifa->ifa_name);
|
||||
new_socket = uwsgi_concat3(new_addr, ":", tcp_port+1);
|
||||
uwsgi_log("found %s for %s on interface %s\n", new_socket, socket_name, ifa->ifa_name);
|
||||
freeifaddrs(ifap);
|
||||
return new_socket;
|
||||
}
|
||||
|
||||
@@ -609,6 +609,12 @@ options_parsed:
|
||||
|
||||
}
|
||||
|
||||
#ifdef UWSGI_PROXY
|
||||
if (uwsgi.proxy_add_me) {
|
||||
uwsgi_cluster_add_node(uwsgi.sockets[0].name, 1, CLUSTER_NODE_STATIC);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//call after_opt hooks
|
||||
|
||||
@@ -1652,7 +1658,12 @@ end:
|
||||
return 1;
|
||||
#ifdef UWSGI_PROXY
|
||||
case LONG_ARGS_PROXY_NODE:
|
||||
uwsgi_cluster_add_node(optarg, 1, CLUSTER_NODE_STATIC);
|
||||
if (uwsgi.cluster_fd >= 0 && !strcmp(optarg, "@self")) {
|
||||
uwsgi.proxy_add_me = 1;
|
||||
}
|
||||
else {
|
||||
uwsgi_cluster_add_node(optarg, 1, CLUSTER_NODE_STATIC);
|
||||
}
|
||||
return 1;
|
||||
case LONG_ARGS_PROXY:
|
||||
uwsgi.proxy_socket_name = optarg;
|
||||
@@ -2080,8 +2091,11 @@ void uwsgi_cluster_add_node(char *nodename, int workers, int type) {
|
||||
if (type == CLUSTER_NODE_DYNAMIC) {
|
||||
free(nodename);
|
||||
}
|
||||
else {
|
||||
tcp_port[0] = ':';
|
||||
}
|
||||
ucn->last_seen = time(NULL);
|
||||
|
||||
uwsgi_log("[uWSGI cluster] added node %s\n", ucn->name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user