diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 0ce06777..201c9d81 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -35,6 +35,26 @@ struct option uwsgi_python_options[] = { {0, 0, 0, 0}, }; +struct uwsgi_help_item uwsgi_python_help[] = { + +{"module " ,"name of python config module"}, +{"optimize ", "set python optimization level to "}, +{"home ", "set python home/virtualenv"}, +{"callable ", "set the callable (default 'application')"}, +{"paste ", "load applications using paste.deploy.loadapp()"}, +{"pythonpath ", "add to PYTHONPATH"}, +{"python-path ", "add to PYTHONPATH"}, +{"pp ", "add to PYTHONPATH"}, +{"pyargv ", "assign args to python sys.argv"}, +{"wsgi-file ", "load the wsgi file"}, +{"file ", "use python file instead of python module for configuration"}, +{"eval ", "evaluate code for app configuration"}, +{"ini-paste ", "path of ini config file that contains paste configuration"}, + + + { 0, 0}, +}; + /* this routine will be called after each fork to reinitialize the various locks */ void uwsgi_python_pthread_prepare(void) { pthread_mutex_lock(&up.lock_pyloaders); @@ -972,8 +992,7 @@ struct uwsgi_plugin python_plugin = { .rpc = uwsgi_python_rpc, .spooler = uwsgi_python_spooler, - /* - .help = uwsgi_python_help, - */ + + .help = uwsgi_python_help, }; diff --git a/uwsgi.c b/uwsgi.c index 3a3063be..dfcd5ae2 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -2137,7 +2137,7 @@ end: uwsgi_load_plugin(-1, p, NULL, 0); p = strtok(NULL, ","); } - build_options(); + build_options(); return 1; case LONG_ARGS_CHDIR: uwsgi.chdir = optarg; @@ -2984,10 +2984,8 @@ struct uwsgi_help_item main_help[] = { {"buffer-size ", "set buffer size to bytes"}, {"disable-logging", "disable request logging (only errors or server messages will be logged)"}, {"xmlconfig ", "path of xml config file"}, -{"module " ,"name of python config module"}, {"harakiri ", "set harakiri timeout to seconds"}, {"processes ", "spawn uwsgi worker processes"}, -{"optimize ", "set python optimization level to "}, {"max-vars ", "set maximum number of vars/headers to "}, {"sharedarea ", "create a shared memory area of pages"}, {"cgi-mode", "set cgi mode"}, @@ -2997,13 +2995,11 @@ struct uwsgi_help_item main_help[] = { {"abstract-socket", "set socket in the abstract namespace (Linux only)"}, {"enable-threads", "enable threads support"}, {"master", "enable master process manager"}, -{"home ", "set python home/virtualenv"}, {"help", "this help"}, {"reaper", "process reaper (call waitpid(-1,...) after each request)"}, {"max-requests", "maximum number of requests for each worker"}, {"test", "test if uWSGI can import a module"}, {"spooler ", "run the spooler on directory "}, -{"callable ", "set the callable (default 'application')"}, {"pidfile ", "write the masterpid to "}, {"chroot ", "chroot to directory (only root)"}, {"gid ", "setgid to (only root)"}, @@ -3012,12 +3008,7 @@ struct uwsgi_help_item main_help[] = { {"chdir2 ", "chdir to after module loading"}, {"no-server", "initialize the uWSGI server then exit. Useful for testing and using uwsgi embedded module"}, {"no-defer-accept", "disable the no-standard way to defer the accept() call (TCP_DEFER_ACCEPT, SO_ACCEPTFILTER...)"}, -{"paste ", "load applications using paste.deploy.loadapp()"}, {"check-interval ", "set the check interval (in seconds) of the master process"}, -{"pythonpath ", "add to PYTHONPATH"}, -{"python-path ", "add to PYTHONPATH"}, -{"pp ", "add to PYTHONPATH"}, -{"pyargv ", "assign args to python sys.argv"}, {"limit-as ", "limit the address space of processes to MB megabytes"}, {"limit-post ", "limit HTTP content_length size to "}, {"post-buffering ", "buffer HTTP POST request higher than to disk"}, @@ -3035,9 +3026,6 @@ struct uwsgi_help_item main_help[] = { {"proxy ", "run the uwsgi proxy on socket "}, {"proxy-node ", "add the node to the proxy"}, {"proxy-max-connections ", "set the max number of concurrent connections mnaged by the proxy"}, -{"wsgi-file ", "load the wsgi file"}, -{"file ", "use python file instead of python module for configuration"}, -{"eval ", "evaluate code for app configuration"}, {"async ", "enable async mode with n core"}, {"logto ", "log to file/udp"}, {"logdate", "add timestamp to loglines"}, @@ -3050,7 +3038,6 @@ struct uwsgi_help_item main_help[] = { {"ignore-script-name", "disable uWSGI management of SCRIPT_NAME"}, {"no-default-app", "do not fallback unknown SCRIPT_NAME requests"}, {"ini ", "path of ini config file"}, -{"ini-paste ", "path of ini config file that contains paste configuration"}, {"ldap ", "url of LDAP uWSGIConfig resource"}, {"ldap-schema", "dump uWSGIConfig LDAP schema"}, {"ldap-schema-ldif", "dump uWSGIConfig LDAP schema in LDIF format"}, @@ -3059,7 +3046,7 @@ struct uwsgi_help_item main_help[] = { {"ugreen-stacksize ", "set uGreen stacksize to "}, {"no-site", "do not import site.py on startup"}, {"vhost", "enable virtual hosting"}, -{"mount MOUNTPOINT=app", "adda new app under MOUNTPOINT"}, +{"mount MOUNTPOINT=app", "add a new app under MOUNTPOINT"}, {"routing", "enable uWSGI advanced routing"}, {"http ", "start embedded HTTP server on "}, {"http-only", "start only the embedded HTTP server"}, @@ -3081,4 +3068,151 @@ struct uwsgi_help_item main_help[] = { void uwsgi_help(void) { + + struct uwsgi_help_item *uhi, *all_help; + int max_size = 0; + struct option *lopt; + int found; + char *space; + char *tmp_option; + int i; + + all_help = main_help; + + build_options(); + + while( (uhi = all_help) ) { + + if (uhi->key == 0) + break; + + if ((int)strlen(uhi->key) > max_size) { + max_size = (int)strlen(uhi->key); + } + + all_help++; + } + + + for (i = 0; i < 0xFF; i++) { + if (uwsgi.p[i]->help) { + + all_help = uwsgi.p[i]->help; + while( (uhi = all_help) ) { + if (uhi->key == 0) break; + if ((int)strlen(uhi->key) > max_size) + max_size = (int)strlen(uhi->key); + all_help++; + } + + } + } + + for (i = 0; i < uwsgi.gp_cnt; i++) { + if (uwsgi.gp[i]->help) { + + all_help = uwsgi.gp[i]->help ; + while( (uhi = all_help) ) { + if (uhi->key == 0) break; + if ((int)strlen(uhi->key) > max_size) + max_size = (int)strlen(uhi->key); + all_help++; + } + + } + } + + fprintf(stdout, "Usage: %s [options...]\n", uwsgi.binary_path); + + lopt = uwsgi.long_options; + + max_size+=4; + + while(lopt->name) { + + found = 0; + + all_help = main_help; + while( (uhi = all_help) ) { + if (uhi->key == 0) break; + + tmp_option = uwsgi_concat2(uhi->key, ""); + space = strchr(tmp_option, ' '); + if (space) space[0] = 0; + + if (!strcmp(tmp_option, lopt->name)) { + found = 1; + break; + } + + free(tmp_option); + all_help++; + } + + if (!found) { + for (i = 0; i < 0xFF; i++) { + if (uwsgi.p[i]->help) { + all_help = uwsgi.p[i]->help; + while( (uhi = all_help) ) { + if (uhi->key == 0) break; + tmp_option = uwsgi_concat2(uhi->key, ""); + space = strchr(tmp_option, ' '); + if (space) space[0] = 0; + + if (!strcmp(tmp_option, lopt->name)) { + found = 1; + break; + } + + free(tmp_option); + all_help++; + } + } + if (found) break; + } + } + + if (!found) { + for (i = 0; i < uwsgi.gp_cnt; i++) { + if (uwsgi.gp[i]->help) { + all_help = uwsgi.gp[i]->help; + while( (uhi = all_help) ) { + if (uhi->key == 0) break; + tmp_option = uwsgi_concat2(uhi->key, ""); + space = strchr(tmp_option, ' '); + if (space) space[0] = 0; + + if (!strcmp(tmp_option, lopt->name)) { + found = 1; + break; + } + + free(tmp_option); + all_help++; + } + } + if (found) break; + } + } + + + if (found) { + if (!lopt->flag && ( (lopt->val >= 'a' && lopt->val <= 'z') || (lopt->val >= 'A' && lopt->val <= 'Z'))) { + fprintf(stdout, " -%c|--%-*s %s\n", lopt->val, max_size-3, uhi->key, uhi->value); + } + else { + fprintf(stdout, " --%-*s %s\n", max_size, uhi->key, uhi->value); + } + if (tmp_option) free(tmp_option); + } + else { + fprintf(stdout, " --%-*s *** UNDOCUMENTED OPTION ***\n", max_size, lopt->name); + } + + lopt++; + } + + exit(0); } + + diff --git a/uwsgi.h b/uwsgi.h index 7c540939..ca73ea29 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -206,6 +206,13 @@ extern int pivot_root(const char * new_root, const char * put_old); #define uwsgi_cache_update_start(x, y, z) uwsgi_cache_set(x, y, "", 0, CACHE_FLAG_UNGETTABLE) +struct uwsgi_help_item { + + char *key; + char *value; +}; + + union uwsgi_sockaddr { struct sockaddr sa; struct sockaddr_in sa_in; @@ -491,6 +498,8 @@ struct uwsgi_plugin { uint16_t (*rpc)(void *, uint8_t, char **, char *); + struct uwsgi_help_item *help; + }; @@ -1642,10 +1651,4 @@ struct uwsgi_async_request { inline int event_queue_read(void); inline int event_queue_write(void); -struct uwsgi_help_item { - - char *key; - char *value; -}; - void uwsgi_help(void); diff --git a/uwsgiconfig.py b/uwsgiconfig.py index d56646e9..8849f0e9 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -335,7 +335,8 @@ class uConf(object): if self.get('udp'): self.cflags.append("-DUWSGI_UDP") - if self.get('pcre'): + # re-enable after pcre fix + if self.get('pcreOFF'): if self.get('pcre') == 'auto': pcreconf = spcall('pcre-config --libs') if pcreconf: