Skip to content

Commit

Permalink
added upstart socket activation support and applied git001 patch for …
Browse files Browse the repository at this point in the history
…additional include paths
  • Loading branch information
roberto@precise64 committed Apr 20, 2012
1 parent 4986bdf commit ab7abc6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
32 changes: 24 additions & 8 deletions uwsgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"xmlconfig", required_argument, 'x', "load config from xml file", uwsgi_opt_load_xml, NULL, UWSGI_OPT_IMMEDIATE},
{"xml", required_argument, 'x', "load config from xml file", uwsgi_opt_load_xml, NULL, UWSGI_OPT_IMMEDIATE},
#endif

{"skip-zero", no_argument, 0, "skip check of file descriptor 0", uwsgi_opt_true, &uwsgi.skip_zero,0},

{"set", required_argument, 'S', "set a custom placeholder", uwsgi_opt_set_placeholder, NULL, UWSGI_OPT_IMMEDIATE},

{"for", required_argument, 0, "(opt logic) for cycle", uwsgi_opt_logic, (void *) uwsgi_logic_opt_for, UWSGI_OPT_IMMEDIATE},
Expand Down Expand Up @@ -2071,10 +2074,9 @@ int uwsgi_start(void *v_argv) {
}
}


if (!uwsgi.no_server) {

// systemd socket activation
// systemd/upstart/zerg socket activation
if (!uwsgi.is_a_reload) {
char *listen_pid = getenv("LISTEN_PID");
if (listen_pid) {
Expand All @@ -2083,20 +2085,33 @@ int uwsgi_start(void *v_argv) {
if (listen_fds) {
int systemd_fds = atoi(listen_fds);
if (systemd_fds > 0) {
uwsgi_log("- SystemD socket activation detected -\n");
for(i=3;i<3+systemd_fds;i++) {
uwsgi_sock = uwsgi_new_socket(NULL);
uwsgi_add_socket_from_fd(uwsgi_sock, i);
}
uwsgi.skip_zero = 1;
}
unsetenv("LISTEN_PID");
unsetenv("LISTEN_FDS");
goto skipzero;
}
}
}
}

if (!uwsgi.is_a_reload) {
char *upstart_events = getenv("UPSTART_EVENTS");
if (upstart_events && !strcmp(upstart_events, "socket")) {
char *upstart_fds = getenv("UPSTART_FDS");
if (upstart_fds) {
uwsgi_log("- Upstart socket bridge detected (job: %s) -\n", getenv("UPSTART_JOB"));
uwsgi_sock = uwsgi_new_socket(NULL);
uwsgi_add_socket_from_fd(uwsgi_sock, atoi(upstart_fds));
uwsgi.skip_zero = 1;
}
unsetenv("UPSTART_EVENTS");
unsetenv("UPSTART_FDS");
}


struct uwsgi_string_list *zn = uwsgi.zerg_node;
while (zn) {
if (uwsgi_zerg_attach(zn->value)) {
Expand Down Expand Up @@ -2129,6 +2144,7 @@ int uwsgi_start(void *v_argv) {
}
}


//check for inherited sockets
if (uwsgi.is_a_reload) {

Expand Down Expand Up @@ -2218,6 +2234,8 @@ int uwsgi_start(void *v_argv) {
}
}
}


//now bind all the unbound sockets
uwsgi_sock = uwsgi.sockets;
while (uwsgi_sock) {
Expand Down Expand Up @@ -2277,7 +2295,7 @@ int uwsgi_start(void *v_argv) {
if (!zero_used) {
socket_type_len = sizeof(struct sockaddr_un);
gsa.sa = (struct sockaddr *) &usa;
if (!getsockname(0, gsa.sa, &socket_type_len)) {
if (!uwsgi.skip_zero && !getsockname(0, gsa.sa, &socket_type_len)) {
if (gsa.sa->sa_family == AF_UNIX) {
uwsgi_sock = uwsgi_new_socket(usa.sa_un.sun_path);
uwsgi_sock->family = AF_UNIX;
Expand Down Expand Up @@ -2315,8 +2333,6 @@ int uwsgi_start(void *v_argv) {

}

skipzero:

// check for auto_port socket
uwsgi_sock = uwsgi.sockets;
while (uwsgi_sock) {
Expand Down
1 change: 1 addition & 0 deletions uwsgi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,7 @@ struct uwsgi_server {


int no_orphans;
int skip_zero;

char *chdir;
char *chdir2;
Expand Down
7 changes: 6 additions & 1 deletion uwsgiconfig.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# uWSGI build system

uwsgi_version = '1.2-rc1'
uwsgi_version = '1.2-rc2'

import os
import re
Expand Down Expand Up @@ -306,6 +306,11 @@ def __init__(self, filename, mute=False):
raise
except:
self.include_path = ['/usr/include', '/usr/local/include']

additional_include_paths = self.get('additional_include_paths')
if additional_include_paths:
for ipath in additional_include_paths.split():
self.include_path.append(ipath)

if not mute:
print("detected include path: %s" % self.include_path)
Expand Down

0 comments on commit ab7abc6

Please sign in to comment.