From f0aa9f9fd2a949919d340b3060671e766afa2ce5 Mon Sep 17 00:00:00 2001 From: "roberto@oneiric64" Date: Fri, 27 Jan 2012 17:54:31 +0100 Subject: [PATCH] another part of options refactoring --- plugins/carbon/carbon.c | 18 +++- plugins/fastrouter/fastrouter.c | 27 ++--- plugins/http/http.c | 23 ++-- plugins/nagios/nagios.c | 11 +- plugins/ping/ping_plugin.c | 23 +--- plugins/python/python_plugin.c | 181 ++++++-------------------------- plugins/python/uwsgi_python.h | 18 ---- plugins/rrdtool/rrdtool.c | 9 +- plugins/ugreen/ugreen.c | 20 +--- uwsgi.c | 50 +++++---- uwsgi.h | 9 -- xmlconf.c | 2 +- 12 files changed, 105 insertions(+), 286 deletions(-) diff --git a/plugins/carbon/carbon.c b/plugins/carbon/carbon.c index 44fb18c8..82476003 100644 --- a/plugins/carbon/carbon.c +++ b/plugins/carbon/carbon.c @@ -15,12 +15,14 @@ struct uwsgi_carbon { char *id; } u_carbon; -struct option carbon_options[] = { +struct uwsgi_option carbon_options[] = { +/* {"carbon", required_argument, 0, CARBON_OPT_CARBON}, {"carbon-timeout", required_argument, 0, CARBON_OPT_CARBON_TIMEOUT}, {"carbon-freq", required_argument, 0, CARBON_OPT_CARBON_FREQ}, {"carbon-id", required_argument, 0, CARBON_OPT_CARBON_ID}, - {0, 0, 0, 0}, +*/ + {0, 0, 0, 0, 0, 0, 0}, }; @@ -29,6 +31,7 @@ int carbon_init() { return 0; } +/* int carbon_opt(int i, char *optarg) { switch(i) { @@ -49,6 +52,7 @@ int carbon_opt(int i, char *optarg) { return 0; } +*/ void carbon_post_init() { @@ -97,6 +101,7 @@ void carbon_master_cycle() { unsigned long long total_rss = 0; unsigned long long total_vsz = 0; unsigned long long avg_rt = 0; + unsigned long long total_tx = 0; rlen = snprintf(ptr, 4096, "uwsgi.%s.%s.requests %llu %llu\n", uwsgi.hostname, u_carbon.id, (unsigned long long ) uwsgi.workers[0].requests, (unsigned long long ) uwsgi.current_time); if (rlen < 1) goto clear; @@ -122,6 +127,10 @@ void carbon_master_cycle() { if (rlen < 1) goto clear; if (write(fd, ptr, rlen) <= 0) { uwsgi_error("write()"); goto clear;} + total_tx += uwsgi.workers[i].tx; + rlen = snprintf(ptr, 4096, "uwsgi.%s.%s.worker%d.tx %llu %llu\n", uwsgi.hostname, u_carbon.id, i, (unsigned long long ) uwsgi.workers[i].tx, (unsigned long long ) uwsgi.current_time); + if (rlen < 1) goto clear; + if (write(fd, ptr, rlen) <= 0) { uwsgi_error("write()"); goto clear;} } rlen = snprintf(ptr, 4096, "uwsgi.%s.%s.rss_size %llu %llu\n", uwsgi.hostname, u_carbon.id, (unsigned long long ) total_rss, (unsigned long long ) uwsgi.current_time); @@ -136,6 +145,10 @@ void carbon_master_cycle() { if (rlen < 1) goto clear; if (write(fd, ptr, rlen) <= 0) { uwsgi_error("write()"); goto clear;} + rlen = snprintf(ptr, 4096, "uwsgi.%s.%s.tx %llu %llu\n", uwsgi.hostname, u_carbon.id, (unsigned long long ) total_tx, (unsigned long long ) uwsgi.current_time); + if (rlen < 1) goto clear; + if (write(fd, ptr, rlen) <= 0) { uwsgi_error("write()"); goto clear;} + clear: close(fd); nxt: @@ -148,7 +161,6 @@ nxt: struct uwsgi_plugin carbon_plugin = { .options = carbon_options, - .manage_opt = carbon_opt, .master_cycle = carbon_master_cycle, diff --git a/plugins/fastrouter/fastrouter.c b/plugins/fastrouter/fastrouter.c index eba3c4c7..4c3efe66 100644 --- a/plugins/fastrouter/fastrouter.c +++ b/plugins/fastrouter/fastrouter.c @@ -17,24 +17,6 @@ extern struct uwsgi_server uwsgi; #include "../../lib/corerouter.h" -#define LONG_ARGS_FASTROUTER 150001 -#define LONG_ARGS_FASTROUTER_EVENTS 150002 -#define LONG_ARGS_FASTROUTER_USE_PATTERN 150003 -#define LONG_ARGS_FASTROUTER_USE_BASE 150004 -#define LONG_ARGS_FASTROUTER_SUBSCRIPTION_SERVER 150005 -#define LONG_ARGS_FASTROUTER_TIMEOUT 150006 -#define LONG_ARGS_FASTROUTER_SUBSCRIPTION_SLOT 150007 -#define LONG_ARGS_FASTROUTER_USE_CODE_STRING 150008 -#define LONG_ARGS_FASTROUTER_TOLERANCE 150009 -#define LONG_ARGS_FASTROUTER_STATS 150010 -#define LONG_ARGS_FASTROUTER_ZERG 150011 -#define LONG_ARGS_FASTROUTER_HARAKIRI 150012 -#define LONG_ARGS_FASTROUTER_USE_SOCKET 150013 -#define LONG_ARGS_FASTROUTER_TO 150014 -#define LONG_ARGS_FASTROUTER_POST_BUFFERING 150015 -#define LONG_ARGS_FASTROUTER_POST_BUFFERING_DIR 150016 -#define LONG_ARGS_FASTROUTER_PROCESSES 150017 - #define FASTROUTER_STATUS_FREE 0 #define FASTROUTER_STATUS_CONNECTING 1 #define FASTROUTER_STATUS_RECV_HDR 2 @@ -104,7 +86,8 @@ struct uwsgi_fastrouter { } ufr; -struct option fastrouter_options[] = { +struct uwsgi_option fastrouter_options[] = { +/* {"fastrouter", required_argument, 0, LONG_ARGS_FASTROUTER}, {"fastrouter-processes", required_argument, 0, LONG_ARGS_FASTROUTER_PROCESSES}, {"fastrouter-workers", required_argument, 0, LONG_ARGS_FASTROUTER_PROCESSES}, @@ -127,7 +110,8 @@ struct option fastrouter_options[] = { {"fastrouter-stats-server", required_argument, 0, LONG_ARGS_FASTROUTER_STATS}, {"fastrouter-ss", required_argument, 0, LONG_ARGS_FASTROUTER_STATS}, {"fastrouter-harakiri", required_argument, 0, LONG_ARGS_FASTROUTER_HARAKIRI}, - {0, 0, 0, 0}, +*/ + {0, 0, 0, 0, 0, 0, 0}, }; extern struct uwsgi_server uwsgi; @@ -863,6 +847,7 @@ int fastrouter_init() { return 0; } +/* int fastrouter_opt(int i, char *optarg) { char *cs; @@ -966,13 +951,13 @@ int fastrouter_opt(int i, char *optarg) { } return 0; } +*/ struct uwsgi_plugin fastrouter_plugin = { .name = "fastrouter", .options = fastrouter_options, - .manage_opt = fastrouter_opt, .init = fastrouter_init, }; diff --git a/plugins/http/http.c b/plugins/http/http.c index d1431a8b..c81f046a 100644 --- a/plugins/http/http.c +++ b/plugins/http/http.c @@ -19,14 +19,6 @@ extern struct uwsgi_server uwsgi; #define MAX_HTTP_VEC 128 #define MAX_HTTP_EXTRA_VARS 64 -#define LONG_ARGS_HTTP_EVENTS 300001 -#define LONG_ARGS_HTTP_USE_PATTERN 300002 -#define LONG_ARGS_HTTP_USE_BASE 300003 -#define LONG_ARGS_HTTP_USE_TO 300004 -#define LONG_ARGS_HTTP_SUBSCRIPTION_SERVER 300005 -#define LONG_ARGS_HTTP_TIMEOUT 300006 -#define LONG_ARGS_HTTP_PROCESSES 300007 - #define HTTP_STATUS_FREE 0 #define HTTP_STATUS_CONNECTING 1 #define HTTP_STATUS_RECV 2 @@ -75,7 +67,8 @@ struct uwsgi_http { struct rb_root *timeouts; } uhttp; -struct option http_options[] = { +struct uwsgi_option http_options[] = { +/* {"http", required_argument, 0, LONG_ARGS_HTTP}, {"http-processes", required_argument, 0, LONG_ARGS_HTTP_PROCESSES}, {"http-workers", required_argument, 0, LONG_ARGS_HTTP_PROCESSES}, @@ -91,7 +84,8 @@ struct option http_options[] = { {"http-subscription-use-regexp", no_argument, &uhttp.subscription_regexp, 1}, {"http-timeout", required_argument, 0, LONG_ARGS_HTTP_TIMEOUT}, {"http-manage-expect", no_argument, &uhttp.manage_expect, 1}, - {0, 0, 0, 0}, +*/ + {0, 0, 0, 0, 0, 0, 0}, }; extern struct uwsgi_server uwsgi; @@ -984,11 +978,7 @@ int http_init() { return 0; } -struct uwsgi_help_item http_help[] = { - {"http-to ", "forward http requests to uwsgi instance bound at "}, - {0, 0} -}; - +/* int http_opt(int i, char *optarg) { struct uwsgi_gateway_socket *ugs; @@ -1042,6 +1032,7 @@ int http_opt(int i, char *optarg) { } return 0; } +*/ @@ -1049,7 +1040,5 @@ struct uwsgi_plugin http_plugin = { .name = "http", .options = http_options, - .manage_opt = http_opt, - .help = http_help, .init = http_init, }; diff --git a/plugins/nagios/nagios.c b/plugins/nagios/nagios.c index 76b64a54..36483813 100644 --- a/plugins/nagios/nagios.c +++ b/plugins/nagios/nagios.c @@ -3,12 +3,10 @@ extern struct uwsgi_server uwsgi; int use_nagios = 0; -#define LONG_ARGS_NAGIOS 40000 +struct uwsgi_option nagios_options[] = { -struct option nagios_options[] = { - - {"nagios", no_argument, 0, LONG_ARGS_NAGIOS}, - {0, 0, 0, 0}, + //{"nagios", no_argument, 0, LONG_ARGS_NAGIOS}, + {0, 0, 0, 0, 0, 0, 0}, }; @@ -70,6 +68,7 @@ int nagios() { exit(3); } +/* int nagios_opt(int i, char *optarg) { switch(i) { @@ -81,10 +80,10 @@ int nagios_opt(int i, char *optarg) { return 0; } +*/ struct uwsgi_plugin nagios_plugin = { .options = nagios_options, - .manage_opt = nagios_opt, .init = nagios, }; diff --git a/plugins/ping/ping_plugin.c b/plugins/ping/ping_plugin.c index 0ebc8b76..0c8e3e2a 100644 --- a/plugins/ping/ping_plugin.c +++ b/plugins/ping/ping_plugin.c @@ -7,9 +7,9 @@ struct uwsgi_ping { int ping_timeout; } uping; -struct option uwsgi_ping_options[] = { - {"ping", required_argument, 0, LONG_ARGS_PING}, - {"ping-timeout", required_argument, 0, LONG_ARGS_PING_TIMEOUT}, +struct uwsgi_option uwsgi_ping_options[] = { + //{"ping", required_argument, 0, "ping specified uwsgi host", uwsgi_opt_ping, NULL, 0}, + {"ping-timeout", required_argument, 0, "set ping timeout", uwsgi_opt_set_int, &uping.ping_timeout, 0}, { 0, 0, 0, 0 } }; @@ -91,28 +91,11 @@ int uwsgi_request_ping(struct wsgi_request *wsgi_req) { return UWSGI_OK; } -int uwsgi_ping_manage_options(int i, char *optarg) { - - switch(i) { - case LONG_ARGS_PING: - uwsgi.no_initial_output = 1; - uwsgi.no_server = 1; - uping.ping = optarg; - return 1; - case LONG_ARGS_PING_TIMEOUT: - uping.ping_timeout = atoi(optarg); - return 1; - } - - return 0; -} - struct uwsgi_plugin ping_plugin = { .name = "ping", .modifier1 = 100, .options = uwsgi_ping_options, - .manage_opt = uwsgi_ping_manage_options, .request = uwsgi_request_ping, .init = ping_init, }; diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index bacf5eb9..943280bd 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -9,21 +9,25 @@ extern struct http_status_codes hsc[]; extern PyTypeObject uwsgi_InputType; -struct option uwsgi_python_options[] = { - {"wsgi-file", required_argument, 0, LONG_ARGS_WSGI_FILE}, - {"file", required_argument, 0, LONG_ARGS_FILE_CONFIG}, - {"eval", required_argument, 0, LONG_ARGS_EVAL_CONFIG}, - {"module", required_argument, 0, 'w'}, - {"wsgi", required_argument, 0, 'w'}, - {"callable", required_argument, 0, LONG_ARGS_CALLABLE}, - {"test", required_argument, 0, 'J'}, - {"home", required_argument, 0, 'H'}, - {"virtualenv", required_argument, 0, 'H'}, - {"venv", required_argument, 0, 'H'}, - {"pyhome", required_argument, 0, 'H'}, +struct uwsgi_option uwsgi_python_options[] = { + {"wsgi-file", required_argument, 0, "load .wsgi file", uwsgi_opt_set_str, &up.file_config, 0}, + {"file", required_argument, 0, "load .wsgi file", uwsgi_opt_set_str, &up.file_config, 0}, + {"eval", required_argument, 0, "eval python code", uwsgi_opt_set_str, &up.eval, 0}, + {"module", required_argument,'w', "load a WSGI module", uwsgi_opt_set_str, &up.wsgi_config, 0}, + {"wsgi", required_argument, 'w', "load a WSGI module", uwsgi_opt_set_str, &up.wsgi_config, 0}, + {"callable", required_argument, 0, "set default WSGI callable name", uwsgi_opt_set_str, &up.callable, 0}, + {"test", required_argument, 'J', "test a mdule import", uwsgi_opt_set_str, &up.test_module, 0}, + {"home", required_argument, 'H', "set PYTHONHOME/virtualenv", uwsgi_opt_set_str, &up.home, 0}, + {"virtualenv", required_argument, 'H', "set PYTHONHOME/virtualenv", uwsgi_opt_set_str, &up.home, 0}, + {"venv", required_argument, 'H', "set PYTHONHOME/virtualenv", uwsgi_opt_set_str, &up.home, 0}, + {"pyhome", required_argument, 'H', "set PYTHONHOME/virtualenv", uwsgi_opt_set_str, &up.home, 0}, + +/* {"pythonpath", required_argument, 0, LONG_ARGS_PYTHONPATH}, {"python-path", required_argument, 0, LONG_ARGS_PYTHONPATH}, + {"pp", required_argument, 0, LONG_ARGS_PYTHONPATH}, {"pymodule-alias", required_argument, 0, LONG_ARGS_PYMODULE_ALIAS}, + {"post-pymodule-alias", required_argument, 0, LONG_ARGS_POST_PYMODULE_ALIAS}, {"import", required_argument, 0, LONG_ARGS_PYIMPORT}, {"pyimport", required_argument, 0, LONG_ARGS_PYIMPORT}, @@ -37,17 +41,24 @@ struct option uwsgi_python_options[] = { {"spooler-pyimport", required_argument, 0, LONG_ARGS_SPOOLER_PYIMPORT}, {"spooler-py-import", required_argument, 0, LONG_ARGS_SPOOLER_PYIMPORT}, {"spooler-python-import", required_argument, 0, LONG_ARGS_SPOOLER_PYIMPORT}, - {"pp", required_argument, 0, LONG_ARGS_PYTHONPATH}, - {"pyargv", required_argument, 0, LONG_ARGS_PYARGV}, - {"optimize", required_argument, 0, 'O'}, - {"paste", required_argument, 0, LONG_ARGS_PASTE}, +*/ + + {"pyargv", required_argument, 0, "manually set sys.argv", uwsgi_opt_set_str, &up.argv, 0}, + {"optimize", required_argument, 'O', "set python optimization level", uwsgi_opt_set_int, &up.optimize, 0}, + + //{"paste", required_argument, 0, LONG_ARGS_PASTE}, + + +/* {"web3", required_argument, 0, LONG_ARGS_WEB3}, {"pump", required_argument, 0, LONG_ARGS_PUMP}, {"wsgi-lite", required_argument, 0, LONG_ARGS_WSGI_LITE}, +*/ #ifdef UWSGI_INI - {"ini-paste", required_argument, 0, LONG_ARGS_INI_PASTE}, + //{"ini-paste", required_argument, 0, LONG_ARGS_INI_PASTE}, #endif - {"catch-exceptions", no_argument, &up.catch_exceptions, 1}, + {"catch-exceptions", no_argument, 0, "report exception has http output (discouraged)", uwsgi_opt_true, &up.catch_exceptions, 0}, +/* {"ignore-script-name", no_argument, &up.ignore_script_name, 1}, {"pep3333-input", no_argument, &up.pep3333_input, 1}, {"reload-os-env", no_argument, &up.reload_os_env, 1}, @@ -58,32 +69,9 @@ struct option uwsgi_python_options[] = { {"pyshell-oneshot", no_argument, 0, LONG_ARGS_PYSHELL_ONESHOT}, {"python", required_argument, 0, LONG_ARGS_PYTHON_RUN}, {"py", required_argument, 0, LONG_ARGS_PYTHON_RUN}, +*/ - {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"}, -{"pyhome ", "set python home/virtualenv"}, -{"virtualenv ", "set python home/virtualenv"}, -{"venv ", "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"}, -{"pyshell", "run a python interactive shell in the uwsgi environment (steals a worker)"}, - - - { 0, 0}, + {0, 0, 0, 0, 0, 0, 0}, }; /* this routine will be called after each fork to reinitialize the various locks */ @@ -752,110 +740,6 @@ int uwsgi_python_magic(char *mountpoint, char *lazy) { } -int uwsgi_python_manage_options(int i, char *optarg) { - - glob_t g; - int j; - - switch (i) { - case 'w': - up.wsgi_config = optarg; - return 1; - case LONG_ARGS_WSGI_FILE: - case LONG_ARGS_FILE_CONFIG: - up.file_config = optarg; - return 1; - case LONG_ARGS_EVAL_CONFIG: - up.eval = optarg; - return 1; - case LONG_ARGS_PYMODULE_ALIAS: - if (up.pymodule_alias_cnt < MAX_PYMODULE_ALIAS) { - up.pymodule_alias[up.pymodule_alias_cnt] = optarg; - up.pymodule_alias_cnt++; - } - else { - uwsgi_log("you can specify at most %d --pymodule-alias options\n", MAX_PYMODULE_ALIAS); - } - return 1; - case LONG_ARGS_PYSHELL: - uwsgi.honour_stdin = 1; - up.pyshell = 1; - return 1; - case LONG_ARGS_PYSHELL_ONESHOT: - uwsgi.honour_stdin = 1; - up.pyshell = 1; - up.pyshell_oneshot = 1; - return 1; - case LONG_ARGS_SHARED_PYIMPORT: - uwsgi_string_new_list(&up.shared_import_list, optarg); - return 1; - case LONG_ARGS_PYIMPORT: - uwsgi_string_new_list(&up.import_list, optarg); - return 1; - case LONG_ARGS_SPOOLER_PYIMPORT: - uwsgi_string_new_list(&up.spooler_import_list, optarg); - return 1; - case LONG_ARGS_POST_PYMODULE_ALIAS: - uwsgi_string_new_list(&up.post_pymodule_alias, optarg); - return 1; - case LONG_ARGS_PYTHONPATH: - if (glob(optarg, GLOB_MARK, NULL, &g)) { - uwsgi_string_new_list(&up.python_path, optarg); - } - else { - for (j = 0; j < (int) g.gl_pathc; j++) { - uwsgi_string_new_list(&up.python_path, g.gl_pathv[j]); - } - } - return 1; - case LONG_ARGS_PYARGV: - up.argv = optarg; - return 1; - case 'J': - up.test_module = optarg; - return 1; - case 'H': - up.home = optarg; - return 1; - case 'O': - up.optimize = atoi(optarg); - return 1; - case LONG_ARGS_CALLABLE: - up.callable = optarg; - return 1; - - -#ifdef UWSGI_INI - case LONG_ARGS_INI_PASTE: - uwsgi_string_new_list(&uwsgi.ini,optarg); - if (optarg[0] != '/') { - up.paste = uwsgi_concat4("config:", uwsgi.cwd, "/", optarg); - } - else { - up.paste = uwsgi_concat2("config:", optarg); - } - return 1; -#endif - case LONG_ARGS_WEB3: - up.web3 = optarg; - return 1; - case LONG_ARGS_PUMP: - up.pump = optarg; - return 1; - case LONG_ARGS_WSGI_LITE: - up.wsgi_lite = optarg; - return 1; - case LONG_ARGS_PASTE: - up.paste = optarg; - return 1; - - - - } - - return 0; -} - int uwsgi_python_mount_app(char *mountpoint, char *app, int regexp) { int id; @@ -1573,8 +1457,6 @@ struct uwsgi_plugin python_plugin = { .init = uwsgi_python_init, .post_fork = uwsgi_python_post_fork, .options = uwsgi_python_options, - .manage_opt = uwsgi_python_manage_options, - .short_options = "w:O:H:J:", .request = uwsgi_request_wsgi, .after_request = uwsgi_after_request_wsgi, @@ -1612,6 +1494,5 @@ struct uwsgi_plugin python_plugin = { .code_string = uwsgi_python_code_string, - .help = uwsgi_python_help, }; diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h index e325c966..96131216 100644 --- a/plugins/python/uwsgi_python.h +++ b/plugins/python/uwsgi_python.h @@ -6,24 +6,6 @@ #define MAX_PYMODULE_ALIAS 64 #define MAX_PYARGV 10 -#define LONG_ARGS_PYTHON_BASE 17000 + ((0 + 1) * 1000) - -#define LONG_ARGS_PYTHONPATH LONG_ARGS_PYTHON_BASE + 1 -#define LONG_ARGS_PASTE LONG_ARGS_PYTHON_BASE + 2 -#define LONG_ARGS_PYARGV LONG_ARGS_PYTHON_BASE + 3 -#define LONG_ARGS_PYMODULE_ALIAS LONG_ARGS_PYTHON_BASE + 4 -#define LONG_ARGS_RELOAD_OS_ENV LONG_ARGS_PYTHON_BASE + 5 -#define LONG_ARGS_PYIMPORT LONG_ARGS_PYTHON_BASE + 6 -#define LONG_ARGS_POST_PYMODULE_ALIAS LONG_ARGS_PYTHON_BASE + 7 -#define LONG_ARGS_WEB3 LONG_ARGS_PYTHON_BASE + 8 -#define LONG_ARGS_PUMP LONG_ARGS_PYTHON_BASE + 9 -#define LONG_ARGS_WSGI_LITE LONG_ARGS_PYTHON_BASE + 10 -#define LONG_ARGS_PYSHELL LONG_ARGS_PYTHON_BASE + 11 -#define LONG_ARGS_SPOOLER_PYIMPORT LONG_ARGS_PYTHON_BASE + 12 -#define LONG_ARGS_PYTHON_RUN LONG_ARGS_PYTHON_BASE + 13 -#define LONG_ARGS_SHARED_PYIMPORT LONG_ARGS_PYTHON_BASE + 14 -#define LONG_ARGS_PYSHELL_ONESHOT LONG_ARGS_PYTHON_BASE + 15 - #define PYTHON_APP_TYPE_WSGI 0 #define PYTHON_APP_TYPE_WEB3 1 #define PYTHON_APP_TYPE_WSGI2 2 diff --git a/plugins/rrdtool/rrdtool.c b/plugins/rrdtool/rrdtool.c index 68f9d53c..00c13fac 100644 --- a/plugins/rrdtool/rrdtool.c +++ b/plugins/rrdtool/rrdtool.c @@ -18,11 +18,13 @@ struct uwsgi_rrdtool { char *update_area; } u_rrd; -struct option rrdtool_options[] = { +struct uwsgi_option rrdtool_options[] = { +/* {"rrdtool", required_argument, 0, RRDTOOL_OPT_RRDTOOL}, {"rrdtool-freq", required_argument, 0, RRDTOOL_OPT_RRDTOOL_FREQ}, {"rrdtool-max-ds", required_argument, 0, RRDTOOL_OPT_RRDTOOL_MAX_DS}, - {0, 0, 0, 0}, +*/ + {0, 0, 0, 0, 0, 0, 0}, }; @@ -51,6 +53,7 @@ int rrdtool_init() { return 0; } +/* int rrdtool_opt(int i, char *optarg) { switch(i) { @@ -68,6 +71,7 @@ int rrdtool_opt(int i, char *optarg) { return 0; } +*/ void rrdtool_post_init() { @@ -188,7 +192,6 @@ void rrdtool_master_cycle() { struct uwsgi_plugin rrdtool_plugin = { .options = rrdtool_options, - .manage_opt = rrdtool_opt, .master_cycle = rrdtool_master_cycle, diff --git a/plugins/ugreen/ugreen.c b/plugins/ugreen/ugreen.c index 2c4cd770..87ab42f1 100644 --- a/plugins/ugreen/ugreen.c +++ b/plugins/ugreen/ugreen.c @@ -21,10 +21,10 @@ struct uwsgi_ugreen { extern struct uwsgi_server uwsgi; -struct option ugreen_options[] = { - {"ugreen", no_argument, &ug.ugreen, 1}, - {"ugreen-stacksize", required_argument, 0, LONG_ARGS_UGREEN_PAGES}, - { 0, 0, 0, 0 } +struct uwsgi_option ugreen_options[] = { + {"ugreen", no_argument, 0, "enable ugreen coroutine subsystem", uwsgi_opt_true, &ug.ugreen, 1}, + {"ugreen-stacksize", required_argument, 0, "set ugreen stack size in pages", uwsgi_opt_set_int, &ug.stackpages, 0}, + { 0, 0, 0, 0, 0, 0, 0 } }; void u_green_request() { @@ -126,21 +126,9 @@ int u_green_init() { } -int uwsgi_ugreen_manage_opt(int i, char *optarg) { - - switch(i) { - case LONG_ARGS_UGREEN_PAGES: - ug.stackpages = atoi(optarg); - return 1; - } - - return 0; -} - struct uwsgi_plugin ugreen_plugin = { .name = "ugreen", .init = u_green_init, .options = ugreen_options, - .manage_opt = uwsgi_ugreen_manage_opt, }; diff --git a/uwsgi.c b/uwsgi.c index e2cb9850..6f60cb64 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -72,14 +72,14 @@ static struct uwsgi_option uwsgi_base_options[] = { {"cgi-mode", no_argument, 'c', "force CGI-mode for plugins supporting it", uwsgi_opt_set_dyn, (void *) UWSGI_OPTION_CGI_MODE,0}, {"abstract-socket", no_argument, 'a', "force UNIX socket in abstract mode (Linux only)", uwsgi_opt_true, &uwsgi.abstract_socket,0}, //{"chmod-socket|chmod", optional_argument, 'C', "chmod-socket", uwsgi_opt_set_mode, &uwsgi.chmod_socket,0}, -// {"chown-socket", required_argument, 0, LONG_ARGS_CHOWN_SOCKET,0}, + {"chown-socket", required_argument, 0, "chown unix sockets", uwsgi_opt_set_str, &uwsgi.chown_socket, 0}, //{"umask", required_argument, 0, "set umask", uwsgi_opt_set_umask, NULL, UWSGI_OPT_IMMEDIATE}, #ifdef __linux__ {"freebind", no_argument, 0, "put socket in freebind mode", uwsgi_opt_true, &uwsgi.freebind,0}, #endif // {"map-socket", required_argument, 0, LONG_ARGS_MAP_SOCKET,0}, #ifdef UWSGI_THREADING -// {"enable-threads", no_argument, 0, 'T',0}, + {"enable-threads", no_argument, 'T', "enable threads", uwsgi_opt_true, &uwsgi.has_threads, 0}, #endif {"auto-procname", no_argument, 0, "automatically set processes name to something meaningful", uwsgi_opt_true, &uwsgi.auto_procname,0}, /* @@ -88,15 +88,15 @@ static struct uwsgi_option uwsgi_base_options[] = { {"procname-append", required_argument, 0, LONG_ARGS_PROCNAME_APPEND,0}, {"procname", required_argument, 0, LONG_ARGS_PROCNAME,0}, {"procname-master", required_argument, 0, LONG_ARGS_PROCNAME_MASTER,0}, - {"single-interpreter", no_argument, 0, 'i',0}, */ + {"single-interpreter", no_argument, 'i', "do not use multiple interpreters (where available)", uwsgi_opt_true, &uwsgi.single_interpreter, 0}, {"master", no_argument, 'M', "enable master process", uwsgi_opt_true, &uwsgi.master_process,0}, {"emperor", required_argument, 0, "run the Emperor", uwsgi_opt_set_str, &uwsgi.emperor_dir,0}, {"emperor-tyrant", no_argument, 0, "put the Emperor in Tyrant mode", uwsgi_opt_true, &uwsgi.emperor_tyrant,0}, + {"emperor-stats", required_argument, 0, "run the Emperor stats server", uwsgi_opt_set_str, &uwsgi.emperor_stats, 0}, + {"emperor-stats-server", required_argument, 0, "run the Emperor stats server", uwsgi_opt_set_str, &uwsgi.emperor_stats, 0}, + {"early-emperor", no_argument, 0, "spawn the emperor as soon as possibile", uwsgi_opt_true, &uwsgi.early_emperor, 0}, /* - {"emperor-stats", required_argument, 0, LONG_ARGS_EMPEROR_STATS,0}, - {"emperor-stats-server", required_argument, 0, LONG_ARGS_EMPEROR_STATS,0}, - {"early-emperor", no_argument, &uwsgi.early_emperor, 1,0}, {"emperor-broodlord", required_argument, 0, LONG_ARGS_EMPEROR_BROODLORD,0}, {"emperor-amqp-vhost", required_argument, 0, LONG_ARGS_EMPEROR_AMQP_VHOST,0}, {"emperor-amqp-username", required_argument, 0, LONG_ARGS_EMPEROR_AMQP_USERNAME,0}, @@ -107,10 +107,10 @@ static struct uwsgi_option uwsgi_base_options[] = { {"vassals-stop-hook", required_argument, 0, LONG_ARGS_VASSALS_STOP_HOOK,0}, {"vassal-sos-backlog", required_argument, 0, LONG_ARGS_VASSAL_SOS_BACKLOG,0}, {"auto-snapshot", optional_argument, 0, LONG_ARGS_AUTO_SNAPSHOT,0}, - {"reload-mercy", required_argument, 0, LONG_ARGS_RELOAD_MERCY,0}, */ + {"reload-mercy", required_argument, 0, "set the maximum time (in seconds) a worker can take to reload/shutdown", uwsgi_opt_set_int, &uwsgi.reload_mercy, 0}, {"exit-on-reload", no_argument, 0, "force exit even if a reload is requested", uwsgi_opt_true, &uwsgi.exit_on_reload,0}, -// {"die-on-term", no_argument, &uwsgi.die_on_term, 1,0}, + {"die-on-term", no_argument, 0, "exit instead of brutal reload on SIGTERM", uwsgi_opt_true, &uwsgi.die_on_term, 0}, //{"help|usage", no_argument, 'h', "show this help", uwsgi_opt_help, NULL,0}, //{"reaper", no_argument, 'r', "call waitpid(-1,...) after each request to get rid of zombies", uwsgi_opt_true, &uwsgi.process_reaper,0}, //{"max-requests", required_argument, 'R', "reload workers after the specified amount of managed requests", uwsgi_opt_set_long, &uwsgi.max_requests,0}, @@ -118,13 +118,15 @@ static struct uwsgi_option uwsgi_base_options[] = { {"socket-timeout", required_argument, 0, 'z',0}, {"no-fd-passing", no_argument, &uwsgi.no_fd_passing, 1,0}, {"locks", required_argument, 0, LONG_ARGS_LOCKS,0}, - {"sharedarea", required_argument, 0, 'A',0}, */ - //{"cache", required_argument, 0, "create a shared cache containing given elements", uwsgi_opt_create_cache, NULL,0}, + {"sharedarea", required_argument, 'A', "create a raw shared memory area of specified pages", uwsgi_opt_set_int, &uwsgi.sharedareasize, 0}, + {"cache", required_argument, 0, "create a shared cache containing given elements", uwsgi_opt_set_int, &uwsgi.cache_max_items, 0}, /* {"cache-blocksize", required_argument, 0, LONG_ARGS_CACHE_BLOCKSIZE,0}, {"cache-store", required_argument, 0, LONG_ARGS_CACHE_STORE,0}, - {"cache-store-sync", required_argument, 0, LONG_ARGS_CACHE_STORE_SYNC,0}, +*/ + {"cache-store-sync", required_argument, 0, "set frequency of sync for persistent cache", uwsgi_opt_set_int, &uwsgi.cache_store_sync,0}, +/* {"cache-server", required_argument, 0, LONG_ARGS_CACHE_SERVER,0}, {"cache-server-threads", required_argument, 0, LONG_ARGS_CACHE_SERVER_THREADS,0}, {"queue", required_argument, 0, LONG_ARGS_QUEUE,0}, @@ -135,7 +137,7 @@ static struct uwsgi_option uwsgi_base_options[] = { #ifdef UWSGI_SPOOLER //{"spooler", required_argument, 'Q', "run a spooler on the specified directory", uwsgi_opt_new_spooler, NULL,0}, {"spooler-ordered", no_argument, 0, "try to order the execution of spooler tasks", uwsgi_opt_true, &uwsgi.spooler_ordered,0}, -// {"spooler-chdir", required_argument, 0, LONG_ARGS_SPOOLER_CHDIR,0}, + {"spooler-chdir", required_argument, 0, "chdir() to specified directory before each spooler task", uwsgi_opt_set_str, &uwsgi.spooler_chdir,0}, #endif /* {"mule", optional_argument, 0, LONG_ARGS_MULE,0}, @@ -144,8 +146,8 @@ static struct uwsgi_option uwsgi_base_options[] = { {"signal-bufsize", required_argument, 0, LONG_ARGS_SIGNAL_BUFSIZE,0}, {"signals-bufsize", required_argument, 0, LONG_ARGS_SIGNAL_BUFSIZE,0}, {"farm", required_argument, 0, LONG_ARGS_FARM,0}, - {"disable-logging", no_argument, 0, 'L',0}, */ + {"disable-logging", no_argument, 'L', "disable request logging", uwsgi_opt_set_dyn, (void *) UWSGI_OPTION_LOGGING, 0}, {"pidfile", required_argument, 0, "create pidfile (before privileges drop)", uwsgi_opt_set_str, &uwsgi.pidfile,0}, {"pidfile2", required_argument, 0, "create pidfile (after privileges drop)", uwsgi_opt_set_str, &uwsgi.pidfile2,0}, @@ -274,26 +276,30 @@ static struct uwsgi_option uwsgi_base_options[] = { {"master-as-root", no_argument, 0, "leave master process running as root", uwsgi_opt_true, &uwsgi.master_as_root,0}, {"chdir", required_argument, 0, "chdir to specified directory before apps loading", uwsgi_opt_set_str, &uwsgi.chdir, 0}, {"chdir2", required_argument, 0, "chdir to specified directory after apps loading", uwsgi_opt_set_str, &uwsgi.chdir2, 0}, + {"lazy", no_argument, 0, "set lazy mode (load apps in workers instead of master)", uwsgi_opt_true, &uwsgi.lazy, 0}, + {"cheap", no_argument, 0, "set cheap mode (spawn workers only after the first request)", uwsgi_opt_true, &uwsgi.cheap, 0}, /* - {"lazy", no_argument, &uwsgi.lazy, 1,0}, - {"cheap", no_argument, &uwsgi.cheap, 1,0}, {"cheaper", required_argument, 0, LONG_ARGS_CHEAPER,0}, {"cheaper-step", required_argument, 0, LONG_ARGS_CHEAPER_STEP,0}, */ - {"idle", required_argument, 0, "set idle mode", uwsgi_opt_set_int, &uwsgi.idle, 0}, + {"idle", required_argument, 0, "set idle mode (put uWSGI in cheap mode after inactivity)", uwsgi_opt_set_int, &uwsgi.idle, 0}, + {"die-on-idle", no_argument, 0, "shutdown uWSGI when idle", uwsgi_opt_true, &uwsgi.die_on_idle, 0}, /* - {"die-on-idle", no_argument, &uwsgi.die_on_idle, 1,0}, {"mount", required_argument, 0, LONG_ARGS_MOUNT,0}, #ifdef UWSGI_PCRE {"regexp-mount", required_argument, 0, LONG_ARGS_REGEXP_MOUNT,0}, #endif - {"grunt", no_argument, &uwsgi.grunt, 1,0}, +*/ + {"grunt", no_argument, 0, "enable grunt mode (in-request fork)", uwsgi_opt_true, &uwsgi.grunt, 0}, +/* {"threads", required_argument, 0, LONG_ARGS_THREADS,0}, {"threads-stacksize", required_argument, 0, LONG_ARGS_THREADS_STACKSIZE,0}, {"thread-stacksize", required_argument, 0, LONG_ARGS_THREADS_STACKSIZE,0}, {"threads-stack-size", required_argument, 0, LONG_ARGS_THREADS_STACKSIZE,0}, {"thread-stack-size", required_argument, 0, LONG_ARGS_THREADS_STACKSIZE,0}, - {"vhost", no_argument, &uwsgi.vhost, 1,0}, +*/ + {"vhost", no_argument, 0, "enable virtualhosting mode (based on SERVER_NAME variable)", uwsgi_opt_true, &uwsgi.vhost, 0}, +/* {"vhost-host", no_argument, 0, LONG_ARGS_VHOSTHOST,0}, #ifdef UWSGI_ROUTING {"routing", no_argument, &uwsgi.routing, 1,0}, @@ -309,8 +315,8 @@ static struct uwsgi_option uwsgi_base_options[] = { {"file-serve-mode", required_argument, 0, LONG_ARGS_FILE_SERVE_MODE,0}, {"fileserve-mode", required_argument, 0, LONG_ARGS_FILE_SERVE_MODE,0}, {"check-cache", no_argument, &uwsgi.check_cache, 1,0}, - {"close-on-exec", no_argument, &uwsgi.close_on_exec, 1,0}, */ + {"close-on-exec", no_argument, 0, "set close-on-exec on sockets (could be required for spawning processes in requests)", uwsgi_opt_true, &uwsgi.close_on_exec, 0}, {"mode", required_argument, 0, "set uWSGI custom mode", uwsgi_opt_set_str, &uwsgi.mode,0}, /* {"env", required_argument, 0, LONG_ARGS_ENV,0}, @@ -342,8 +348,8 @@ static struct uwsgi_option uwsgi_base_options[] = { {"dump-options", no_argument, 0, "dump the full list of available options", uwsgi_opt_true, &uwsgi.dump_options,0}, {"show-config", no_argument, 0, "show the current config reformatted as ini", uwsgi_opt_true, &uwsgi.show_config,0}, {"print", required_argument, 0, "simple print", uwsgi_opt_print, NULL,0}, - {"version", no_argument, 0, "print uWSGI version", uwsgi_opt_print, UWSGI_VERSION,0}, - {0, 0, 0, 0} + {"version", no_argument, 0, "print uWSGI version", uwsgi_opt_print, UWSGI_VERSION, 0}, + {0, 0, 0, 0, 0, 0, 0} }; void show_config(void) { diff --git a/uwsgi.h b/uwsgi.h index 3ffdf60f..352ae4f1 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -275,12 +275,6 @@ 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; -}; - struct uwsgi_config_template { char *filename; int applied; @@ -559,8 +553,6 @@ struct uwsgi_plugin { void (*post_init) (void); void (*post_fork) (void); struct uwsgi_option *options; - const char *short_options; - int (*manage_opt) (int, char *); void (*enable_threads) (void); void (*init_thread) (int); int (*request) (struct wsgi_request *); @@ -595,7 +587,6 @@ struct uwsgi_plugin { int (*mule)(char *); int (*mule_msg)(char *, size_t); - struct uwsgi_help_item *help; }; diff --git a/xmlconf.c b/xmlconf.c index 8a2b1190..d087efb7 100644 --- a/xmlconf.c +++ b/xmlconf.c @@ -90,7 +90,7 @@ void uwsgi_xml_config(char *filename, struct wsgi_request *wsgi_req, int app_tag for (node = element->children; node; node = node->next) { if (node->type == XML_CDATA_SECTION_NODE) { if (node->content) { - manage_opt(LONG_ARGS_EVAL_CONFIG, (char *) node->content); + uwsgi_manage_opt("eval", (char *) node->content); } } else if (node->type == XML_ELEMENT_NODE) {