From 2c19a031c75e6c6e67eb5ea3520ee04daf786872 Mon Sep 17 00:00:00 2001 From: "roberto@longshot" Date: Sat, 26 Feb 2011 20:28:26 +0100 Subject: [PATCH] added --processes auto --- buildconf/unbit.ini | 13 ++++--------- ldap.c | 37 ------------------------------------- master.c | 4 +++- uwsgi.c | 23 ++++++++++++++++++++++- 4 files changed, 29 insertions(+), 48 deletions(-) diff --git a/buildconf/unbit.ini b/buildconf/unbit.ini index c397f240..af8f9b4a 100644 --- a/buildconf/unbit.ini +++ b/buildconf/unbit.ini @@ -1,28 +1,23 @@ [uwsgi] xml = true ini = true +yaml = true snmp = false sctp = false -erlang = false spooler = true embedded = true -udp = false +udp = true multicast = false threading = true sendfile = true nagios = false -proxy = false minterpreters = true async = true -http = false -evdis = false -ldap = false -routing = false -stackless = false +ldap = true debug = false unbit = true xml_implementation = libxml2 plugins = bin_name = /opt/unbit/bin/uwsgi plugin_dir = /opt/unbit/uwsgi_plugins -embedded_plugins = python +embedded_plugins = diff --git a/ldap.c b/ldap.c index b69558d0..bf273544 100644 --- a/ldap.c +++ b/ldap.c @@ -44,8 +44,6 @@ void uwsgi_ldap_schema_dump_ldif() { int i; int counter = 30000; - int pythonpath_found = 0; - uwsgi_log("\n"); uwsgi_log("dn: cn=uwsgi,cn=schema,cn=config\n"); uwsgi_log("objectClass: olcSchemaConfig\n"); @@ -55,13 +53,6 @@ void uwsgi_ldap_schema_dump_ldif() { if (!aopt->name) break; - if (aopt->val == LONG_ARGS_PYTHONPATH) { - if (pythonpath_found) { - goto next; - } - pythonpath_found = 1; - } - if (aopt->flag) { uwsgi_log("olcAttributeTypes: ( 1.3.6.1.4.1.35156.17.4.%d NAME 'uWSGI", counter); counter++; @@ -85,7 +76,6 @@ void uwsgi_ldap_schema_dump_ldif() { else { uwsgi_log("' SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )\n"); } -next: lopt++; } @@ -95,18 +85,10 @@ next: uwsgi_log("olcObjectClasses: ( 1.3.6.1.4.1.35156.17.3.1 NAME 'uWSGIConfig' SUP top AUXILIARY DESC 'uWSGI configuration' MAY ( "); - pythonpath_found = 0; while( (aopt = lopt) ) { if (!aopt->name) break; - if (aopt->val == LONG_ARGS_PYTHONPATH) { - if (pythonpath_found) { - goto next2; - } - pythonpath_found = 1; - } - uwsgi_log("uWSGI"); for(i=0;i< (int)strlen(aopt->name);i++) { @@ -119,7 +101,6 @@ next: } } uwsgi_log(" $ "); -next2: lopt++; } @@ -136,20 +117,12 @@ void uwsgi_ldap_schema_dump() { lopt = uwsgi.long_options; int i; int counter = 30000; - int pythonpath_found = 0; while( (aopt = lopt) ) { if (!aopt->name) break; - if (aopt->val == LONG_ARGS_PYTHONPATH) { - if (pythonpath_found) { - goto next; - } - pythonpath_found = 1; - } - if (aopt->flag) { uwsgi_log("attributetype ( 1.3.6.1.4.1.35156.17.4.%d NAME 'uWSGI", counter); counter++; @@ -173,7 +146,6 @@ void uwsgi_ldap_schema_dump() { else { uwsgi_log("' SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )\n"); } -next: lopt++; } @@ -183,18 +155,10 @@ next: uwsgi_log("objectclass ( 1.3.6.1.4.1.35156.17.3.1 NAME 'uWSGIConfig' SUP top AUXILIARY DESC 'uWSGI configuration' MAY ( "); - pythonpath_found = 0; while( (aopt = lopt) ) { if (!aopt->name) break; - if (aopt->val == LONG_ARGS_PYTHONPATH) { - if (pythonpath_found) { - goto next2; - } - pythonpath_found = 1; - } - uwsgi_log("uWSGI"); for(i=0;i< (int)strlen(aopt->name);i++) { @@ -207,7 +171,6 @@ next: } } uwsgi_log(" $ "); -next2: lopt++; } diff --git a/master.c b/master.c index b166f7e1..ac87c4e8 100644 --- a/master.c +++ b/master.c @@ -154,10 +154,10 @@ void master_loop(char **argv, char **environ) { int udp_managed = 0; int udp_fd = -1 ; +#ifdef UWSGI_MULTICAST char *cluster_opt_buf = NULL; int cluster_opt_size = 4; -#ifdef UWSGI_MULTICAST char *cptrbuf; uint16_t ustrlen; struct uwsgi_header *uh; @@ -561,6 +561,7 @@ void master_loop(char **argv, char **environ) { continue; } +#ifdef UWSGI_MULTICAST if (interesting_fd == uwsgi.cluster_fd) { if (uwsgi_get_dgram(uwsgi.cluster_fd, uwsgi.wsgi_requests[0])) { @@ -596,6 +597,7 @@ void master_loop(char **argv, char **environ) { } continue; } +#endif #endif diff --git a/uwsgi.c b/uwsgi.c index 6e629291..7a9c4b05 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -2126,7 +2126,28 @@ end: uwsgi.vec_size = 4 + 1 + (4 * uwsgi.max_vars); return 1; case 'p': - uwsgi.numproc = atoi(optarg); + if (!strcmp(optarg, "auto")) { + struct rlimit rl; + if (getrlimit(RLIMIT_NPROC, &rl)) { + uwsgi_error("getrlimit()"); + uwsgi.numproc = 1; + } + else { + if (rl.rlim_cur == RLIM_INFINITY || rl.rlim_cur > 64) { + uwsgi.numproc = (sysconf(_SC_NPROCESSORS_ONLN))*2; + } + else { + uwsgi.numproc = rl.rlim_cur; + if (uwsgi.numproc > 1) { + uwsgi.numproc--; + uwsgi.master_process = 1; + } + } + } + } + else { + uwsgi.numproc = atoi(optarg); + } return 1; case 'r': uwsgi.shared->options[UWSGI_OPTION_REAPER] = 1;