added listing options for showing internal loaded features

This commit is contained in:
roberto@quantal64
2012-08-23 16:51:56 +02:00
parent 305f8a0667
commit aa075f9aaa
8 changed files with 151 additions and 23 deletions
-3
View File
@@ -938,9 +938,6 @@ void emperor_loop() {
emperor_throttle_level = uwsgi.emperor_throttle;
uwsgi_register_imperial_monitor("dir", uwsgi_imperial_monitor_directory_init, uwsgi_imperial_monitor_directory);
uwsgi_register_imperial_monitor("glob", uwsgi_imperial_monitor_glob_init, uwsgi_imperial_monitor_glob);
// the queue must be initialized before adding scanners
uwsgi.emperor_queue = event_queue_init();
-3
View File
@@ -759,9 +759,6 @@ int master_loop(char **argv, char **environ) {
uwsgi_check_touches(uwsgi.touch_logreopen);
// setup cheaper algos
uwsgi_register_cheaper_algo("spare", uwsgi_cheaper_algo_spare);
uwsgi_register_cheaper_algo("backlog", uwsgi_cheaper_algo_backlog);
uwsgi.cheaper_algo = uwsgi_cheaper_algo_spare;
if (uwsgi.requested_cheaper_algo) {
uwsgi.cheaper_algo = NULL;
+115 -7
View File
@@ -144,6 +144,8 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"emperor-throttle", required_argument, 0, "set throttling level (in milliseconds) for bad behaving vassals (default 1000)", uwsgi_opt_set_int, &uwsgi.emperor_throttle, 0},
{"emperor-max-throttle", required_argument, 0, "set max throttling level (in milliseconds) for bad behaving vassals (default 3 minutes)", uwsgi_opt_set_int, &uwsgi.emperor_max_throttle, 0},
{"emperor-magic-exec", no_argument, 0, "prefix vassals config files with exec:// if they have the executable bit", uwsgi_opt_true, &uwsgi.emperor_magic_exec, 0},
{"imperial-monitor-list", no_argument, 0, "list enabled imperial monitors", uwsgi_opt_true, &uwsgi.imperial_monitor_list, 0},
{"imperial-monitors-list", no_argument, 0, "list enabled imperial monitors", uwsgi_opt_true, &uwsgi.imperial_monitor_list, 0},
{"vassals-inherit", required_argument, 0, "add config templates to vassals config", uwsgi_opt_add_string_list, &uwsgi.vassals_templates, 0},
{"vassals-start-hook", required_argument, 0, "run the specified command before each vassal starts", uwsgi_opt_set_str, &uwsgi.vassals_start_hook, 0},
{"vassals-stop-hook", required_argument, 0, "run the specified command after vassal's death", uwsgi_opt_set_str, &uwsgi.vassals_stop_hook, 0},
@@ -339,6 +341,8 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"log-syslog", optional_argument, 0, "log to syslog", uwsgi_opt_set_logger, "syslog", UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
{"log-socket", required_argument, 0, "send logs to the specified socket", uwsgi_opt_set_logger, "socket", UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
{"logger", required_argument, 0, "set/append a logger", uwsgi_opt_set_logger, NULL, UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
{"logger-list", no_argument, 0, "list enabled loggers", uwsgi_opt_true, &uwsgi.loggers_list, 0},
{"loggers-list", no_argument, 0, "list enabled loggers", uwsgi_opt_true, &uwsgi.loggers_list, 0},
{"threaded-logger", no_argument, 0, "offload log writing to a thread", uwsgi_opt_true, &uwsgi.threaded_logger, UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
#ifdef UWSGI_ZEROMQ
{"log-zeromq", required_argument, 0, "send logs to a zeromq server", uwsgi_opt_set_logger, "zeromq", UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
@@ -373,6 +377,9 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"cheaper-algo", required_argument, 0, "choose to algorithm used for adaptive process spawning)", uwsgi_opt_set_str, &uwsgi.requested_cheaper_algo, UWSGI_OPT_MASTER},
{"cheaper-step", required_argument, 0, "number of additional processes to spawn at each overload", uwsgi_opt_set_int, &uwsgi.cheaper_step, UWSGI_OPT_MASTER | UWSGI_OPT_CHEAPER},
{"cheaper-overload", required_argument, 0, "increase workers after specified overload", uwsgi_opt_set_64bit, &uwsgi.cheaper_overload, UWSGI_OPT_MASTER | UWSGI_OPT_CHEAPER},
{"cheaper-algo-list", no_argument, 0, "list of available cheapers algorithms", uwsgi_opt_true, &uwsgi.cheaper_algo_list, 0},
{"cheaper-algos-list", no_argument, 0, "list of available cheapers algorithms", uwsgi_opt_true, &uwsgi.cheaper_algo_list, 0},
{"cheaper-list", no_argument, 0, "list of available cheapers algorithms", uwsgi_opt_true, &uwsgi.cheaper_algo_list, 0},
{"idle", required_argument, 0, "set idle mode (put uWSGI in cheap mode after inactivity)", uwsgi_opt_set_int, &uwsgi.idle, UWSGI_OPT_MASTER},
{"die-on-idle", no_argument, 0, "shutdown uWSGI when idle", uwsgi_opt_true, &uwsgi.die_on_idle, 0},
{"mount", required_argument, 0, "load application under mountpoint", uwsgi_opt_add_app, NULL, 0},
@@ -395,6 +402,8 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"route-host", required_argument, 0, "add a route based on Host header", uwsgi_opt_add_route, "http_host", 0},
{"route-uri", required_argument, 0, "add a route based on REQUEST_URI", uwsgi_opt_add_route, "request_uri", 0},
{"route-qs", required_argument, 0, "add a route based on QUERY_STRING", uwsgi_opt_add_route, "query_string", 0},
{"router-list", no_argument, 0, "list enabled routers", uwsgi_opt_true, &uwsgi.router_list, 0},
{"routers-list", no_argument, 0, "list enabled routers", uwsgi_opt_true, &uwsgi.router_list, 0},
#endif
{"add-header", required_argument, 0, "automatically add HTTP headers to response", uwsgi_opt_add_string_list, &uwsgi.additional_headers, 0},
@@ -449,12 +458,16 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"cron", required_argument, 0, "add a cron task", uwsgi_opt_add_cron, NULL, UWSGI_OPT_MASTER},
{"loop", required_argument, 0, "select the uWSGI loop engine", uwsgi_opt_set_str, &uwsgi.loop, 0},
{"loop-list", no_argument, 0, "list available loop engines", uwsgi_opt_true, &uwsgi.loop_list, 0},
{"loops-list", no_argument, 0, "list available loop engines", uwsgi_opt_true, &uwsgi.loop_list, 0},
{"worker-exec", required_argument, 0, "run the specified command as worker", uwsgi_opt_set_str, &uwsgi.worker_exec, 0},
{"attach-daemon", required_argument, 0, "attach a command/daemon to the master process (the command has to not go in background)", uwsgi_opt_add_daemon, NULL, UWSGI_OPT_MASTER},
{"plugins", required_argument, 0, "load uWSGI plugins", uwsgi_opt_load_plugin, NULL, UWSGI_OPT_IMMEDIATE},
{"plugin", required_argument, 0, "load uWSGI plugins", uwsgi_opt_load_plugin, NULL, UWSGI_OPT_IMMEDIATE},
{"plugins-dir", required_argument, 0, "add a directory to uWSGI plugin search path", uwsgi_opt_add_string_list, &uwsgi.plugins_dir, UWSGI_OPT_IMMEDIATE},
{"plugin-dir", required_argument, 0, "add a directory to uWSGI plugin search path", uwsgi_opt_add_string_list, &uwsgi.plugins_dir, UWSGI_OPT_IMMEDIATE},
{"plugins-list", no_argument, 0, "list enabled plugins", uwsgi_opt_true, &uwsgi.plugins_list, 0},
{"plugin-list", no_argument, 0, "list enabled plugins", uwsgi_opt_true, &uwsgi.plugins_list, 0},
{"autoload", no_argument, 0, "try to automatically load plugins when unknown options are found", uwsgi_opt_true, &uwsgi.autoload, UWSGI_OPT_IMMEDIATE},
{"allowed-modifiers", required_argument, 0, "comma separated list of allowed modifiers", uwsgi_opt_set_str, &uwsgi.allowed_modifiers, 0},
{"remap-modifier", required_argument, 0, "remap request modifier from one id to another", uwsgi_opt_set_str, &uwsgi.remap_modifier, 0},
@@ -471,16 +484,16 @@ static struct uwsgi_option uwsgi_base_options[] = {
void show_config(void) {
int i;
fprintf(stdout, "\n;uWSGI instance configuration\n[uwsgi]\n");
uwsgi_log("\n;uWSGI instance configuration\n[uwsgi]\n");
for (i = 0; i < uwsgi.exported_opts_cnt; i++) {
if (uwsgi.exported_opts[i]->value) {
fprintf(stdout, "%s = %s\n", uwsgi.exported_opts[i]->key, uwsgi.exported_opts[i]->value);
uwsgi_log("%s = %s\n", uwsgi.exported_opts[i]->key, uwsgi.exported_opts[i]->value);
}
else {
fprintf(stdout, "%s = true\n", uwsgi.exported_opts[i]->key);
uwsgi_log("%s = true\n", uwsgi.exported_opts[i]->key);
}
}
fprintf(stdout, ";end of configuration\n\n");
uwsgi_log(";end of configuration\n\n");
}
@@ -1416,6 +1429,70 @@ check:
}
}
static void plugins_list(void) {
int i;
uwsgi_log("\n*** uWSGI loaded generic plugins ***\n");
for(i=0;i<uwsgi.gp_cnt;i++) {
uwsgi_log("%s\n", uwsgi.gp[i]->name);
}
uwsgi_log("\n*** uWSGI loaded request plugins ***\n");
for(i=0;i<256;i++) {
if (uwsgi.p[i] == &unconfigured_plugin) continue;
uwsgi_log("%d: %s\n", i, uwsgi.p[i]->name);
}
uwsgi_log("--- end of plugins list ---\n\n");
}
static void loggers_list(void) {
struct uwsgi_logger *ul = uwsgi.loggers;
uwsgi_log("\n*** uWSGI loaded loggers ***\n");
while(ul) {
uwsgi_log("%s\n", ul->name);
ul = ul->next;
}
uwsgi_log("--- end of loggers list ---\n\n");
}
static void cheaper_algo_list(void) {
struct uwsgi_cheaper_algo *uca = uwsgi.cheaper_algos;
uwsgi_log("\n*** uWSGI loaded cheaper algorithms ***\n");
while(uca) {
uwsgi_log("%s\n", uca->name);
uca = uca->next;
}
uwsgi_log("--- end of cheaper algorithms list ---\n\n");
}
static void router_list(void) {
struct uwsgi_router *ur = uwsgi.routers;
uwsgi_log("\n*** uWSGI loaded routers ***\n");
while(ur) {
uwsgi_log("%s\n", ur->name);
ur = ur->next;
}
uwsgi_log("--- end of routers list ---\n\n");
}
static void loop_list(void) {
int i;
uwsgi_log("\n*** uWSGI loaded loop engines ***\n");
for(i=0;i<uwsgi.loops_cnt;i++) {
uwsgi_log("%s\n", uwsgi.loops[i].name);
}
uwsgi_log("--- end of loop engines list ---\n\n");
}
static void imperial_monitor_list(void) {
struct uwsgi_imperial_monitor *uim = uwsgi.emperor_monitors;
uwsgi_log("\n*** uWSGI loaded imperial monitors ***\n");
while(uim) {
uwsgi_log("%s\n", uim->scheme);
uim = uim->next;
}
uwsgi_log("--- end of imperial monitors list ---\n\n");
}
#ifdef UWSGI_AS_SHARED_LIBRARY
int uwsgi_init(int argc, char *argv[], char *envp[]) {
@@ -1843,6 +1920,20 @@ int main(int argc, char *argv[], char *envp[]) {
}
// setup loops
uwsgi_register_loop("simple", simple_loop);
#ifdef UWSGI_ASYNC
uwsgi_register_loop("async", async_loop);
#endif
// setup cheaper algos
uwsgi_register_cheaper_algo("spare", uwsgi_cheaper_algo_spare);
uwsgi_register_cheaper_algo("backlog", uwsgi_cheaper_algo_backlog);
// setup imperial monitors
uwsgi_register_imperial_monitor("dir", uwsgi_imperial_monitor_directory_init, uwsgi_imperial_monitor_directory);
uwsgi_register_imperial_monitor("glob", uwsgi_imperial_monitor_glob_init, uwsgi_imperial_monitor_glob);
/* uWSGI IS CONFIGURED !!! */
if (uwsgi.dump_options) {
@@ -1857,6 +1948,26 @@ int main(int argc, char *argv[], char *envp[]) {
if (uwsgi.show_config)
show_config();
if (uwsgi.plugins_list)
plugins_list();
if (uwsgi.loggers_list)
loggers_list();
if (uwsgi.cheaper_algo_list)
cheaper_algo_list();
if (uwsgi.router_list)
router_list();
if (uwsgi.loop_list)
loop_list();
if (uwsgi.imperial_monitor_list)
imperial_monitor_list();
// call cluster initialization procedures
#ifdef UWSGI_MULTICAST
cluster_setup();
@@ -2231,10 +2342,7 @@ int uwsgi_start(void *v_argv) {
}
uwsgi_register_loop("simple", simple_loop);
#ifdef UWSGI_ASYNC
uwsgi_register_loop("async", async_loop);
// TODO rewrite to use uwsgi.max_fd
if (uwsgi.async > 1) {
+2 -3
View File
@@ -450,10 +450,9 @@ void gevent_loop() {
}
int gevent_init() {
void gevent_init() {
uwsgi_register_loop( (char *) "gevent", gevent_loop);
return 0;
}
@@ -461,5 +460,5 @@ struct uwsgi_plugin gevent_plugin = {
.name = "gevent",
.options = gevent_options,
.init = gevent_init,
.on_load = gevent_init,
};
+1
View File
@@ -73,6 +73,7 @@ int nagios() {
struct uwsgi_plugin nagios_plugin = {
.name = "nagios",
.options = nagios_options,
.init = nagios,
};
+2
View File
@@ -163,6 +163,8 @@ void rrdtool_master_cycle() {
}
struct uwsgi_plugin rrdtool_plugin = {
.name = "rrdtool",
.options = rrdtool_options,
+15
View File
@@ -1247,6 +1247,16 @@ struct uwsgi_server {
// show ini representation of the current config
int show_config;
// list loaded features
int cheaper_algo_list;
#ifdef UWSGI_ROUTING
int router_list;
#endif
int imperial_monitor_list;
int plugins_list;
int loggers_list;
int loop_list;
//base for all the requests(even on async mode)
struct wsgi_request **wsgi_requests;
struct wsgi_request *wsgi_req;
@@ -3148,6 +3158,11 @@ void emperor_add(struct uwsgi_emperor_scanner *, char *, time_t, char *, uint32_
void uwsgi_exec_command_with_args(char *);
void uwsgi_imperial_monitor_glob_init(struct uwsgi_emperor_scanner *);
void uwsgi_imperial_monitor_directory_init(struct uwsgi_emperor_scanner *);
void uwsgi_imperial_monitor_directory(struct uwsgi_emperor_scanner *);
void uwsgi_imperial_monitor_glob(struct uwsgi_emperor_scanner *);
#ifdef UWSGI_AS_SHARED_LIBRARY
int uwsgi_init(int, char **, char **);
#endif
+16 -7
View File
@@ -123,12 +123,16 @@ def add_o(x):
return x
def compile(cflags, objfile, srcfile):
def compile(cflags, last_cflags_ts, objfile, srcfile):
source_stat = os.stat(srcfile)
header_stat = os.stat('uwsgi.h')
try:
if os.environ.get('UWSGI_FORCE_REBUILD', None):
raise
if source_stat[8] >= last_cflags_ts:
raise
if header_stat[8] >= last_cflags_ts:
raise
object_stat = os.stat(objfile)
if object_stat[8] <= source_stat[8]:
raise
@@ -184,12 +188,21 @@ def build_uwsgi(uc, print_only=False):
import binascii
uwsgi_cflags = binascii.b2a_hex(' '.join(cflags).encode('ascii')).decode('ascii')
last_cflags_ts = 0
if os.path.exists('uwsgibuild.lastcflags'):
ulc = open('uwsgibuild.lastcflags','r')
last_cflags = ulc.read()
ulc.close()
if uwsgi_cflags != last_cflags:
os.environ['UWSGI_FORCE_REBUILD'] = '1'
else:
last_cflags_ts = os.stat('uwsgibuild.lastcflags')[8]
ulc = open('uwsgibuild.lastcflags','w')
ulc.write(uwsgi_cflags)
ulc.close()
cflags.append('-DUWSGI_CFLAGS=\\"%s\\"' % uwsgi_cflags)
cflags.append('-DUWSGI_BUILD_DATE="\\"%s\\""' % time.strftime("%d %B %Y %H:%M:%S"))
@@ -200,7 +213,7 @@ def build_uwsgi(uc, print_only=False):
if objfile == 'uwsgi':
objfile = 'main'
if not objfile.endswith('.a'):
compile(' '.join(cflags), objfile + '.o', file + '.c')
compile(' '.join(cflags), last_cflags_ts, objfile + '.o', file + '.c')
if uc.get('embedded_plugins'):
ep = uc.get('embedded_plugins').split(',')
@@ -251,7 +264,7 @@ def build_uwsgi(uc, print_only=False):
for cfile in up.GCC_LIST:
if not cfile.endswith('.a'):
compile(' '.join(uniq_warnings(p_cflags)),
compile(' '.join(uniq_warnings(p_cflags)), last_cflags_ts,
path + '/' + cfile + '.o', path + '/' + cfile + '.c')
gcc_list.append('%s/%s' % (path, cfile))
else:
@@ -297,10 +310,6 @@ def build_uwsgi(uc, print_only=False):
for ef in binary_list:
gcc_list.append("build/%s" % ef)
ulc = open('uwsgibuild.lastcflags','w')
ulc.write(uwsgi_cflags)
ulc.close()
print("*** uWSGI linking ***")
ldline = "%s -o %s %s %s %s" % (GCC, bin_name, ' '.join(uniq_warnings(ldflags)),
' '.join(map(add_o, gcc_list)), ' '.join(uniq_warnings(libs)))