mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-10-04 16:08:31 +00:00
Compare commits
60
Commits
intellisurvey
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6005624af | ||
|
|
70198991fe | ||
|
|
df0c2ca1c8 | ||
|
|
da60423252 | ||
|
|
5b9e2b5f39 | ||
|
|
8185b97030 | ||
|
|
abac960e62 | ||
|
|
8ea8a33d0c | ||
|
|
8939fd5e1b | ||
|
|
849a85b250 | ||
|
|
d08275ea12 | ||
|
|
fb3628d729 | ||
|
|
52ea02acad | ||
|
|
59a76bb85c | ||
|
|
26bd4aa489 | ||
|
|
7e601d6d8d | ||
|
|
c2e83fe01d | ||
|
|
281c1f5427 | ||
|
|
33df0dbcc9 | ||
|
|
cd24b11369 | ||
|
|
bbdf4bbab3 | ||
|
|
637ead553a | ||
|
|
5ebc399cce | ||
|
|
e55ac57e07 | ||
|
|
f03f679a5c | ||
|
|
72ae69090a | ||
|
|
1d595be2d9 | ||
|
|
095c75055f | ||
|
|
20a0be1897 | ||
|
|
637952d048 | ||
|
|
a7181572e6 | ||
|
|
920d94c055 | ||
|
|
72647fada7 | ||
|
|
82a011e14d | ||
|
|
772deaa083 | ||
|
|
94ccb6b030 | ||
|
|
01d3133fce | ||
|
|
377fc2d863 | ||
|
|
59df10466a | ||
|
|
ebb77b55d7 | ||
|
|
55c7e653fd | ||
|
|
eab664ae8b | ||
|
|
9a0681a6e0 | ||
|
|
cd69e718aa | ||
|
|
8d2465db9b | ||
|
|
69fb3c8426 | ||
|
|
7cf499127f | ||
|
|
6921e8f820 | ||
|
|
37971671cb | ||
|
|
271c6aa13b | ||
|
|
c375920c63 | ||
|
|
8e28051d2e | ||
|
|
d5114da3aa | ||
|
|
9787f6882c | ||
|
|
7efa3666b7 | ||
|
|
74eb3b282e | ||
|
|
1b59a46fc0 | ||
|
|
92672880d7 | ||
|
|
fb9d063e81 | ||
|
|
5e9e07c64f |
+2
-1
@@ -396,9 +396,10 @@ static int uwsgi_hook_chown2(char *arg) {
|
||||
}
|
||||
|
||||
|
||||
#ifdef __sun__
|
||||
#if defined(UWSGI_SUNOS_EXTERN_SETHOSTNAME)
|
||||
extern int sethostname(char *, int);
|
||||
#endif
|
||||
|
||||
static int uwsgi_hook_hostname(char *arg) {
|
||||
#ifdef __CYGWIN__
|
||||
return -1;
|
||||
|
||||
+27
-1
@@ -62,6 +62,7 @@ void uwsgi_init_default() {
|
||||
|
||||
uwsgi.cpus = 1;
|
||||
uwsgi.new_argc = -1;
|
||||
uwsgi.binary_argc = 1;
|
||||
|
||||
uwsgi.backtrace_depth = 64;
|
||||
uwsgi.max_apps = 64;
|
||||
@@ -261,11 +262,33 @@ void uwsgi_commandline_config() {
|
||||
int argc = uwsgi.argc;
|
||||
char **argv = uwsgi.argv;
|
||||
|
||||
// we might want to ignore some arguments not meant for us
|
||||
char binary_argv0_pretty[256] = {'\0'};
|
||||
char *binary_argv0_actual = NULL;
|
||||
|
||||
if (uwsgi.new_argc > -1 && uwsgi.new_argv) {
|
||||
argc = uwsgi.new_argc;
|
||||
argv = uwsgi.new_argv;
|
||||
}
|
||||
|
||||
if (uwsgi.binary_argc > 1 && argc >= uwsgi.binary_argc) {
|
||||
char *pretty = (char *)binary_argv0_pretty;
|
||||
strncat(pretty, argv[0], 255);
|
||||
|
||||
for (i = 1; i < uwsgi.binary_argc; i++) {
|
||||
if (strlen(pretty) + 1 + strlen(argv[i]) + 1 > 256)
|
||||
break;
|
||||
|
||||
strcat(pretty, " ");
|
||||
strcat(pretty, argv[i]);
|
||||
}
|
||||
|
||||
argc -= uwsgi.binary_argc - 1;
|
||||
argv += uwsgi.binary_argc - 1;
|
||||
|
||||
binary_argv0_actual = argv[0];
|
||||
argv[0] = (char *)binary_argv0_pretty;
|
||||
}
|
||||
|
||||
char *optname;
|
||||
while ((i = getopt_long(argc, argv, uwsgi.short_options, uwsgi.long_options, &uwsgi.option_index)) != -1) {
|
||||
@@ -289,6 +312,8 @@ void uwsgi_commandline_config() {
|
||||
add_exported_option(optname, optarg, 0);
|
||||
}
|
||||
|
||||
if (binary_argv0_actual != NULL)
|
||||
argv[0] = binary_argv0_actual;
|
||||
|
||||
#ifdef UWSGI_DEBUG
|
||||
uwsgi_log("optind:%d argc:%d\n", optind, uwsgi.argc);
|
||||
@@ -413,7 +438,8 @@ pid_t uwsgi_daemonize2() {
|
||||
uwsgi_write_pidfile(uwsgi.pidfile2);
|
||||
}
|
||||
|
||||
if (uwsgi.log_master) uwsgi_setup_log_master();
|
||||
if (uwsgi.log_master)
|
||||
uwsgi_setup_log_master();
|
||||
|
||||
return uwsgi.mypid;
|
||||
}
|
||||
|
||||
+16
-2
@@ -99,7 +99,7 @@ retry:
|
||||
uwsgi_log("unable to set PTHREAD_PRIO_INHERIT\n");
|
||||
exit(1);
|
||||
}
|
||||
if (pthread_mutexattr_setrobust_np(&attr, PTHREAD_MUTEX_ROBUST)) {
|
||||
if (pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST)) {
|
||||
uwsgi_log("unable to make the mutex 'robust'\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -161,7 +161,7 @@ void uwsgi_lock_fast(struct uwsgi_lock_item *uli) {
|
||||
#ifdef EOWNERDEAD
|
||||
if (pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr) == EOWNERDEAD) {
|
||||
uwsgi_log("[deadlock-detector] a process holding a robust mutex died. recovering...\n");
|
||||
pthread_mutex_consistent_np((pthread_mutex_t *) uli->lock_ptr);
|
||||
pthread_mutex_consistent((pthread_mutex_t *) uli->lock_ptr);
|
||||
}
|
||||
#else
|
||||
pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr);
|
||||
@@ -476,6 +476,20 @@ void uwsgi_rwunlock_fast(struct uwsgi_lock_item *uli) {
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __RUMP__
|
||||
int semctl(int _0, int _1, int _2, ...) {
|
||||
return 0;
|
||||
}
|
||||
int semget(key_t _0, int _1, int _2) {
|
||||
return 0;
|
||||
}
|
||||
int semop(int _0, struct sembuf * _1, size_t _2) {
|
||||
return 0;
|
||||
}
|
||||
#undef UWSGI_LOCK_ENGINE_NAME
|
||||
#define UWSGI_LOCK_ENGINE_NAME "fake"
|
||||
#endif
|
||||
|
||||
struct uwsgi_lock_item *uwsgi_lock_ipcsem_init(char *id) {
|
||||
|
||||
// used by ftok
|
||||
|
||||
@@ -1512,6 +1512,7 @@ static void *logger_thread_loop(void *noarg) {
|
||||
if (uwsgi.req_log_master) {
|
||||
logpoll[1].events = POLLIN;
|
||||
logpoll[1].fd = uwsgi.shared->worker_req_log_pipe[0];
|
||||
logpolls++;
|
||||
}
|
||||
|
||||
|
||||
@@ -1551,6 +1552,19 @@ void uwsgi_threaded_logger_spawn() {
|
||||
}
|
||||
}
|
||||
|
||||
void uwsgi_threaded_logger_worker_spawn() {
|
||||
pthread_t logger_thread;
|
||||
|
||||
pthread_mutex_init(&uwsgi.threaded_logger_lock, NULL);
|
||||
|
||||
uwsgi.log_master_buf = uwsgi_malloc(uwsgi.log_master_bufsize);
|
||||
|
||||
if (pthread_create(&logger_thread, NULL, logger_thread_loop, NULL)) {
|
||||
uwsgi_error_safe("uwsgi_threaded_logger_worker_spawn()/pthread_create()");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void uwsgi_register_log_encoder(char *name, char *(*func)(struct uwsgi_log_encoder *, char *, size_t, size_t *)) {
|
||||
struct uwsgi_log_encoder *old_ule = NULL, *ule = uwsgi.log_encoders;
|
||||
|
||||
|
||||
@@ -772,6 +772,7 @@ int uwsgi_respawn_worker(int wid) {
|
||||
for(i=0;i<uwsgi.cores;i++) {
|
||||
uwsgi.workers[uwsgi.mywid].cores[i].in_request = 0;
|
||||
memset(&uwsgi.workers[uwsgi.mywid].cores[i].req, 0, sizeof(struct wsgi_request));
|
||||
memset(uwsgi.workers[uwsgi.mywid].cores[i].buffer, 0, sizeof(struct uwsgi_header));
|
||||
}
|
||||
|
||||
uwsgi_fixup_fds(wid, 0, NULL);
|
||||
|
||||
+1
-1
@@ -715,7 +715,7 @@ next:
|
||||
}
|
||||
|
||||
if (uwsgi.manage_script_name) {
|
||||
if (uwsgi_apps_cnt > 0 && wsgi_req->path_info_len > 1 && wsgi_req->path_info_pos != -1) {
|
||||
if (uwsgi_apps_cnt > 0 && wsgi_req->path_info_len >= 1 && wsgi_req->path_info_pos != -1) {
|
||||
// starts with 1 as the 0 app is the default (/) one
|
||||
int best_found = 0;
|
||||
char *orig_path_info = wsgi_req->path_info;
|
||||
|
||||
+5
-4
@@ -467,8 +467,7 @@ cycle:
|
||||
return received_signal;
|
||||
}
|
||||
|
||||
void uwsgi_receive_signal(struct wsgi_request *wsgi_req, int fd, char *name, int id) {
|
||||
|
||||
int uwsgi_receive_signal(struct wsgi_request *wsgi_req, int fd, char *name, int id) {
|
||||
uint8_t uwsgi_signal;
|
||||
|
||||
ssize_t ret = read(fd, &uwsgi_signal, 1);
|
||||
@@ -487,13 +486,15 @@ void uwsgi_receive_signal(struct wsgi_request *wsgi_req, int fd, char *name, int
|
||||
if (uwsgi_signal_handler(wsgi_req, uwsgi_signal)) {
|
||||
uwsgi_log_verbose("error managing signal %d on %s %d\n", uwsgi_signal, name, id);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
return;
|
||||
return 0;
|
||||
|
||||
destroy:
|
||||
// better to kill the whole worker...
|
||||
uwsgi_log_verbose("uWSGI %s %d screams: UAAAAAAH my master disconnected: I will kill myself!!!\n", name, id);
|
||||
end_me(0);
|
||||
|
||||
// never here
|
||||
return 0;
|
||||
}
|
||||
|
||||
+13
-1
@@ -465,7 +465,15 @@ void spooler(struct uwsgi_spooler *uspool) {
|
||||
if (event_queue_wait(spooler_event_queue, timeout, &interesting_fd) > 0) {
|
||||
if (uwsgi.master_process) {
|
||||
if (interesting_fd == uwsgi.shared->spooler_signal_pipe[1]) {
|
||||
uwsgi_receive_signal(NULL, interesting_fd, "spooler", (int) getpid());
|
||||
if (uwsgi_receive_signal(NULL, interesting_fd, "spooler", (int) getpid())) {
|
||||
if (uwsgi.spooler_signal_as_task) {
|
||||
uspool->tasks++;
|
||||
if (uwsgi.spooler_max_tasks > 0 && uspool->tasks >= (uint64_t) uwsgi.spooler_max_tasks) {
|
||||
uwsgi_log("[spooler %s pid: %d] maximum number of tasks reached (%d) recycling ...\n", uspool->dir, (int) uwsgi.mypid, uwsgi.spooler_max_tasks);
|
||||
end_me(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,7 +496,11 @@ static void spooler_scandir(struct uwsgi_spooler *uspool, char *dir) {
|
||||
if (!dir)
|
||||
dir = uspool->dir;
|
||||
|
||||
#ifdef __NetBSD__
|
||||
n = scandir(dir, &tasklist, NULL, (void *)uwsgi_versionsort);
|
||||
#else
|
||||
n = scandir(dir, &tasklist, NULL, uwsgi_versionsort);
|
||||
#endif
|
||||
if (n < 0) {
|
||||
uwsgi_error("scandir()");
|
||||
return;
|
||||
|
||||
+1
-1
@@ -459,7 +459,7 @@ int uwsgi_real_file_serve(struct wsgi_request *wsgi_req, char *real_filename, si
|
||||
}
|
||||
}
|
||||
#ifdef UWSGI_DEBUG
|
||||
uwsgi_log("[uwsgi-fileserve] file %s found\n", real_filename);
|
||||
uwsgi_log("[uwsgi-fileserve] file %s found, mimetype %s\n", real_filename, mime_type);
|
||||
#endif
|
||||
|
||||
// static file - don't update avg_rt after request
|
||||
|
||||
@@ -333,9 +333,11 @@ void uwsgi_as_root() {
|
||||
if (getuid() > 0)
|
||||
goto nonroot;
|
||||
|
||||
#ifndef __RUMP__
|
||||
if (!uwsgi.master_as_root && !uwsgi.uidname) {
|
||||
uwsgi_log_initial("uWSGI running as root, you can use --uid/--gid/--chroot options\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
int in_jail = 0;
|
||||
|
||||
@@ -905,9 +907,11 @@ void uwsgi_as_root() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __RUMP__
|
||||
if (!getuid()) {
|
||||
uwsgi_log_initial("*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** \n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef UWSGI_CAP
|
||||
|
||||
|
||||
+43
-4
@@ -326,6 +326,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
{"spooler-processes", required_argument, 0, "set the number of processes for spoolers", uwsgi_opt_set_int, &uwsgi.spooler_numproc, UWSGI_OPT_IMMEDIATE},
|
||||
{"spooler-quiet", no_argument, 0, "do not be verbose with spooler tasks", uwsgi_opt_true, &uwsgi.spooler_quiet, 0},
|
||||
{"spooler-max-tasks", required_argument, 0, "set the maximum number of tasks to run before recycling a spooler", uwsgi_opt_set_int, &uwsgi.spooler_max_tasks, 0},
|
||||
{"spooler-signal-as-task", no_argument, 0, "treat signal events as tasks in spooler, combine used with spooler-max-tasks", uwsgi_opt_true, &uwsgi.spooler_signal_as_task, 0},
|
||||
{"spooler-harakiri", required_argument, 0, "set harakiri timeout for spooler tasks", uwsgi_opt_set_int, &uwsgi.harakiri_options.spoolers, 0},
|
||||
{"spooler-frequency", required_argument, 0, "set spooler frequency", uwsgi_opt_set_int, &uwsgi.spooler_frequency, 0},
|
||||
{"spooler-freq", required_argument, 0, "set spooler frequency", uwsgi_opt_set_int, &uwsgi.spooler_frequency, 0},
|
||||
@@ -713,6 +714,8 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
{"req-logger", required_argument, 0, "set/append a request logger", uwsgi_opt_set_req_logger, NULL, UWSGI_OPT_REQ_LOG_MASTER},
|
||||
{"logger-req", required_argument, 0, "set/append a request logger", uwsgi_opt_set_req_logger, NULL, UWSGI_OPT_REQ_LOG_MASTER},
|
||||
{"logger", required_argument, 0, "set/append a logger", uwsgi_opt_set_logger, NULL, UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
|
||||
{"worker-logger", required_argument, 0, "set/append a logger in single-worker setup", uwsgi_opt_set_worker_logger, NULL, 0},
|
||||
{"worker-logger-req", required_argument, 0, "set/append a request logger in single-worker setup", uwsgi_opt_set_req_logger, NULL, 0},
|
||||
{"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},
|
||||
@@ -720,6 +723,9 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
|
||||
{"log-encoder", required_argument, 0, "add an item in the log encoder chain", uwsgi_opt_add_string_list, &uwsgi.requested_log_encoders, UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
|
||||
{"log-req-encoder", required_argument, 0, "add an item in the log req encoder chain", uwsgi_opt_add_string_list, &uwsgi.requested_log_req_encoders, UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
|
||||
|
||||
{"worker-log-encoder", required_argument, 0, "add an item in the log encoder chain", uwsgi_opt_add_string_list, &uwsgi.requested_log_encoders, 0},
|
||||
{"worker-log-req-encoder", required_argument, 0, "add an item in the log req encoder chain", uwsgi_opt_add_string_list, &uwsgi.requested_log_req_encoders, 0},
|
||||
|
||||
|
||||
#ifdef UWSGI_PCRE
|
||||
@@ -1689,6 +1695,18 @@ next:
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uwsgi.master_fifo) {
|
||||
// also remove all master fifo
|
||||
struct uwsgi_string_list *usl;
|
||||
uwsgi_foreach(usl, uwsgi.master_fifo) {
|
||||
if (unlink(usl->value)) {
|
||||
uwsgi_error("unlink()");
|
||||
}
|
||||
else {
|
||||
uwsgi_log("VACUUM: master fifo %s removed.\n", usl->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1832,7 +1850,7 @@ void uwsgi_plugins_atexit(void) {
|
||||
|
||||
void uwsgi_backtrace(int depth) {
|
||||
|
||||
#if (defined(__linux__) && !defined(__UCLIBC__))|| (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO)
|
||||
#if (defined(__GLIBC__) && !defined(__UCLIBC__))|| (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO)
|
||||
|
||||
#include <execinfo.h>
|
||||
|
||||
@@ -2080,7 +2098,6 @@ void uwsgi_setup(int argc, char *argv[], char *envp[]) {
|
||||
|
||||
int i;
|
||||
|
||||
struct utsname uuts;
|
||||
|
||||
// signal mask is inherited, and sme process manager could make a real mess...
|
||||
sigset_t smask;
|
||||
@@ -2353,6 +2370,13 @@ configure:
|
||||
// setup master logging
|
||||
if (uwsgi.log_master)
|
||||
uwsgi_setup_log_master();
|
||||
else if (uwsgi.numproc == 1 && uwsgi.log_worker && uwsgi.master_process == 0) {
|
||||
// hack for allowing request loggers
|
||||
if (uwsgi.requested_req_logger)
|
||||
uwsgi.req_log_master = 1;
|
||||
uwsgi_setup_log_master();
|
||||
uwsgi_threaded_logger_worker_spawn();
|
||||
}
|
||||
|
||||
// setup offload engines
|
||||
uwsgi_offload_engines_register_all();
|
||||
@@ -2435,6 +2459,10 @@ configure:
|
||||
|
||||
uwsgi_log_initial("compiled with version: %s on %s\n", __VERSION__, UWSGI_BUILD_DATE);
|
||||
|
||||
#ifdef __RUMP__
|
||||
uwsgi_log_initial("Rump system detected\n");
|
||||
#else
|
||||
struct utsname uuts;
|
||||
#ifdef __sun__
|
||||
if (uname(&uuts) < 0) {
|
||||
#else
|
||||
@@ -2447,6 +2475,7 @@ configure:
|
||||
uwsgi_log_initial("nodename: %s\n", uuts.nodename);
|
||||
uwsgi_log_initial("machine: %s\n", uuts.machine);
|
||||
}
|
||||
#endif
|
||||
|
||||
uwsgi_log_initial("clock source: %s\n", uwsgi.clock->name);
|
||||
#ifdef UWSGI_PCRE
|
||||
@@ -2659,10 +2688,13 @@ int uwsgi_start(void *v_argv) {
|
||||
uwsgi_write_pidfile(uwsgi.pidfile2);
|
||||
}
|
||||
|
||||
#ifndef __RUMP__
|
||||
if (!uwsgi.master_process && !uwsgi.command_mode) {
|
||||
uwsgi_log_initial("*** WARNING: you are running uWSGI without its master process manager ***\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __RUMP__
|
||||
#ifdef RLIMIT_NPROC
|
||||
if (uwsgi.rl_nproc.rlim_max > 0) {
|
||||
uwsgi.rl_nproc.rlim_cur = uwsgi.rl_nproc.rlim_max;
|
||||
@@ -2682,6 +2714,8 @@ int uwsgi_start(void *v_argv) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __OpenBSD__
|
||||
|
||||
if (uwsgi.rl.rlim_max > 0) {
|
||||
@@ -3856,8 +3890,8 @@ void uwsgi_init_all_apps() {
|
||||
what++;
|
||||
for (j = 0; j < 256; j++) {
|
||||
if (uwsgi.p[j]->mount_app) {
|
||||
uwsgi_log("mounting %s on %s\n", what, app_mps->value);
|
||||
if (uwsgi.p[j]->mount_app(app_mps->value, what) != -1)
|
||||
uwsgi_log("mounting %s on %s\n", what, app_mps->value[0] == 0 ? "/" : app_mps->value);
|
||||
if (uwsgi.p[j]->mount_app(app_mps->value[0] == 0 ? "/" : app_mps->value, what) != -1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -4152,6 +4186,11 @@ void uwsgi_opt_set_logger(char *opt, char *value, void *prefix) {
|
||||
}
|
||||
}
|
||||
|
||||
void uwsgi_opt_set_worker_logger(char *opt, char *value, void *prefix) {
|
||||
uwsgi_opt_set_logger(opt, value, prefix);
|
||||
uwsgi.log_worker = 1;
|
||||
}
|
||||
|
||||
void uwsgi_opt_set_req_logger(char *opt, char *value, void *prefix) {
|
||||
|
||||
if (!value)
|
||||
|
||||
+2432
-494
File diff suppressed because it is too large
Load Diff
@@ -711,7 +711,11 @@ PyObject *uwsgi_paste_loader(void *arg1) {
|
||||
exit(UWSGI_FAILED_APP_CODE);
|
||||
}
|
||||
|
||||
paste_arg = PyTuple_New(1);
|
||||
if (up.paste_name) {
|
||||
paste_arg = PyTuple_New(2);
|
||||
} else {
|
||||
paste_arg = PyTuple_New(1);
|
||||
}
|
||||
if (!paste_arg) {
|
||||
PyErr_Print();
|
||||
exit(UWSGI_FAILED_APP_CODE);
|
||||
@@ -722,6 +726,13 @@ PyObject *uwsgi_paste_loader(void *arg1) {
|
||||
exit(UWSGI_FAILED_APP_CODE);
|
||||
}
|
||||
|
||||
if (up.paste_name) {
|
||||
if (PyTuple_SetItem(paste_arg, 1, UWSGI_PYFROMSTRING(up.paste_name))) {
|
||||
PyErr_Print();
|
||||
exit(UWSGI_FAILED_APP_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
paste_app = PyEval_CallObject(paste_loadapp, paste_arg);
|
||||
if (!paste_app) {
|
||||
PyErr_Print();
|
||||
|
||||
@@ -149,6 +149,7 @@ struct uwsgi_option uwsgi_python_options[] = {
|
||||
|
||||
{"paste", required_argument, 0, "load a paste.deploy config file", uwsgi_opt_set_str, &up.paste, 0},
|
||||
{"paste-logger", no_argument, 0, "enable paste fileConfig logger", uwsgi_opt_true, &up.paste_logger, 0},
|
||||
{"paste-name", required_argument, 0, "specify the name of the paste section", uwsgi_opt_set_str, &up.paste_name, 0},
|
||||
|
||||
|
||||
{"web3", required_argument, 0, "load a web3 app", uwsgi_opt_set_str, &up.web3, 0},
|
||||
@@ -204,15 +205,18 @@ struct uwsgi_option uwsgi_python_options[] = {
|
||||
|
||||
/* 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);
|
||||
if (!up.is_dynamically_loading_an_app)
|
||||
pthread_mutex_lock(&up.lock_pyloaders);
|
||||
}
|
||||
|
||||
void uwsgi_python_pthread_parent(void) {
|
||||
pthread_mutex_unlock(&up.lock_pyloaders);
|
||||
if (!up.is_dynamically_loading_an_app)
|
||||
pthread_mutex_unlock(&up.lock_pyloaders);
|
||||
}
|
||||
|
||||
void uwsgi_python_pthread_child(void) {
|
||||
pthread_mutex_init(&up.lock_pyloaders, NULL);
|
||||
if (!up.is_dynamically_loading_an_app)
|
||||
pthread_mutex_init(&up.lock_pyloaders, NULL);
|
||||
}
|
||||
|
||||
PyMethodDef uwsgi_spit_method[] = { {"uwsgi_spit", py_uwsgi_spit, METH_VARARGS, ""} };
|
||||
|
||||
@@ -11,8 +11,7 @@ extern struct uwsgi_plugin python_plugin;
|
||||
|
||||
|
||||
PyTypeObject uwsgi_RequestContextType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"uwsgi.RequestContext",
|
||||
sizeof(uwsgi_RequestContext),
|
||||
0,
|
||||
|
||||
@@ -154,6 +154,7 @@ struct uwsgi_python {
|
||||
char *file_config;
|
||||
char *paste;
|
||||
int paste_logger;
|
||||
char *paste_name;
|
||||
char *eval;
|
||||
|
||||
char *web3;
|
||||
@@ -213,6 +214,9 @@ struct uwsgi_python {
|
||||
|
||||
int call_osafterfork;
|
||||
int pre_initialized;
|
||||
|
||||
// when 1 we have the app-loading lock held
|
||||
int is_dynamically_loading_an_app;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -71,11 +71,14 @@ if 'UWSGI_PYTHON_NOLIB' not in os.environ:
|
||||
LIBS.append('-lutil')
|
||||
else:
|
||||
try:
|
||||
LDFLAGS.append("-L%s" % sysconfig.get_config_var('LIBDIR'))
|
||||
os.environ['LD_RUN_PATH'] = "%s" % (sysconfig.get_config_var('LIBDIR'))
|
||||
libdir = sysconfig.get_config_var('LIBDIR')
|
||||
except:
|
||||
LDFLAGS.append("-L%s/lib" % sysconfig.PREFIX)
|
||||
os.environ['LD_RUN_PATH'] = "%s/lib" % sysconfig.PREFIX
|
||||
libdir = "%s/lib" % sysconfig.PREFIX
|
||||
|
||||
LDFLAGS.append("-L%s" % libdir)
|
||||
LDFLAGS.append("-Wl,-rpath=%s" % libdir)
|
||||
|
||||
os.environ['LD_RUN_PATH'] = "%s" % libdir
|
||||
|
||||
LIBS.append('-lpython%s' % get_python_version())
|
||||
else:
|
||||
|
||||
@@ -339,6 +339,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
|
||||
// this part must be heavy locked in threaded modes
|
||||
if (uwsgi.threads > 1) {
|
||||
pthread_mutex_lock(&up.lock_pyloaders);
|
||||
up.is_dynamically_loading_an_app = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,6 +364,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
|
||||
|
||||
if (wsgi_req->dynamic) {
|
||||
if (uwsgi.threads > 1) {
|
||||
up.is_dynamically_loading_an_app = 0;
|
||||
pthread_mutex_unlock(&up.lock_pyloaders);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ struct uwsgi_rados_mountpoint {
|
||||
char *allow_delete;
|
||||
char *allow_mkcol;
|
||||
char *allow_propfind;
|
||||
char *username;
|
||||
};
|
||||
|
||||
static struct uwsgi_option uwsgi_rados_options[] = {
|
||||
@@ -405,6 +406,7 @@ static void uwsgi_rados_add_mountpoint(char *arg, size_t arg_len) {
|
||||
"allow_delete", &urmp->allow_delete,
|
||||
"allow_mkcol", &urmp->allow_mkcol,
|
||||
"allow_propfind", &urmp->allow_propfind,
|
||||
"username", &urmp->username,
|
||||
NULL)) {
|
||||
uwsgi_log("unable to parse rados mountpoint definition\n");
|
||||
exit(1);
|
||||
@@ -423,7 +425,7 @@ static void uwsgi_rados_add_mountpoint(char *arg, size_t arg_len) {
|
||||
uwsgi_log("[rados] mounting %s ...\n", urmp->mountpoint);
|
||||
|
||||
rados_t cluster;
|
||||
if (rados_create(&cluster, NULL) < 0) {
|
||||
if (rados_create(&cluster, urmp->username) < 0) {
|
||||
uwsgi_error("can't create Ceph cluster handle");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,14 @@ it exports values exposed by the metric subsystem
|
||||
|
||||
extern struct uwsgi_server uwsgi;
|
||||
|
||||
struct uwsgi_stats_pusher_statsd {
|
||||
int no_workers;
|
||||
} u_stats_pusher_statsd;
|
||||
|
||||
static struct uwsgi_option stats_pusher_statsd_options[] = {
|
||||
{"statsd-no-workers", no_argument, 0, "disable generation of single worker metrics", uwsgi_opt_true, &u_stats_pusher_statsd.no_workers, 0}
|
||||
};
|
||||
|
||||
// configuration of a statsd node
|
||||
struct statsd_node {
|
||||
int fd;
|
||||
@@ -86,6 +94,9 @@ static void stats_pusher_statsd(struct uwsgi_stats_pusher_instance *uspi, time_t
|
||||
struct uwsgi_buffer *ub = uwsgi_buffer_new(uwsgi.page_size);
|
||||
struct uwsgi_metric *um = uwsgi.metrics;
|
||||
while(um) {
|
||||
if (u_stats_pusher_statsd.no_workers && !uwsgi_starts_with(um->name, um->name_len, "worker.", 7)) {
|
||||
goto next;
|
||||
}
|
||||
uwsgi_rlock(uwsgi.metrics_lock);
|
||||
// ignore return value
|
||||
if (um->type == UWSGI_METRIC_GAUGE) {
|
||||
@@ -100,6 +111,7 @@ static void stats_pusher_statsd(struct uwsgi_stats_pusher_instance *uspi, time_t
|
||||
*um->value = um->initial_value;
|
||||
uwsgi_rwunlock(uwsgi.metrics_lock);
|
||||
}
|
||||
next:
|
||||
um = um->next;
|
||||
}
|
||||
uwsgi_buffer_destroy(ub);
|
||||
@@ -114,6 +126,7 @@ static void stats_pusher_statsd_init(void) {
|
||||
struct uwsgi_plugin stats_pusher_statsd_plugin = {
|
||||
|
||||
.name = "stats_pusher_statsd",
|
||||
.options = stats_pusher_statsd_options,
|
||||
.on_load = stats_pusher_statsd_init,
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ import os
|
||||
NAME = 'systemd_logger'
|
||||
|
||||
CFLAGS = os.popen('pkg-config --cflags libsystemd-journal').read().rstrip().split()
|
||||
CFLAGS += os.popen('pkg-config --cflags libsystemd').read().rstrip().split()
|
||||
LDFLAGS = []
|
||||
LIBS = os.popen('pkg-config --libs libsystemd-journal').read().rstrip().split()
|
||||
LIBS += os.popen('pkg-config --libs libsystemd').read().rstrip().split()
|
||||
GCC_LIST = ['systemd_logger']
|
||||
|
||||
@@ -153,22 +153,7 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#ifdef __UCLIBC__
|
||||
#include <sched.h>
|
||||
#endif
|
||||
#undef _GNU_SOURCE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <signal.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__) || defined(__GNUC__)
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
@@ -176,6 +161,14 @@ extern "C" {
|
||||
#define __USE_GNU
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <signal.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#ifdef __linux__
|
||||
@@ -183,7 +176,6 @@ extern "C" {
|
||||
#define MSG_FASTOPEN 0x20000000
|
||||
#endif
|
||||
#endif
|
||||
#undef _GNU_SOURCE
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <termios.h>
|
||||
@@ -269,6 +261,9 @@ extern int pivot_root(const char *new_root, const char *put_old);
|
||||
#include <stdint.h>
|
||||
|
||||
#include <sys/wait.h>
|
||||
#ifndef WAIT_ANY
|
||||
#define WAIT_ANY (-1)
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#ifndef MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
@@ -344,6 +339,9 @@ extern int pivot_root(const char *new_root, const char *put_old);
|
||||
#ifdef __sun__
|
||||
#undef __EXTENSIONS__
|
||||
#endif
|
||||
#ifdef _GNU_SOURCE
|
||||
#undef _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#define UWSGI_CACHE_FLAG_UNGETTABLE 0x01
|
||||
#define UWSGI_CACHE_FLAG_UPDATE 1 << 1
|
||||
@@ -2375,6 +2373,7 @@ struct uwsgi_server {
|
||||
int spooler_quiet;
|
||||
int spooler_frequency;
|
||||
|
||||
|
||||
int snmp;
|
||||
char *snmp_addr;
|
||||
char *snmp_community;
|
||||
@@ -2808,6 +2807,13 @@ struct uwsgi_server {
|
||||
|
||||
char *emperor_trigger_socket;
|
||||
int emperor_trigger_socket_fd;
|
||||
|
||||
int spooler_signal_as_task;
|
||||
|
||||
int log_worker;
|
||||
|
||||
// number of args to consider part of binary_path
|
||||
int binary_argc;
|
||||
};
|
||||
|
||||
struct uwsgi_rpc {
|
||||
@@ -3800,6 +3806,7 @@ void uwsgi_opt_set_str(char *, char *, void *);
|
||||
void uwsgi_opt_custom(char *, char *, void *);
|
||||
void uwsgi_opt_set_null(char *, char *, void *);
|
||||
void uwsgi_opt_set_logger(char *, char *, void *);
|
||||
void uwsgi_opt_set_worker_logger(char *, char *, void *);
|
||||
void uwsgi_opt_set_req_logger(char *, char *, void *);
|
||||
void uwsgi_opt_set_str_spaced(char *, char *, void *);
|
||||
void uwsgi_opt_add_string_list(char *, char *, void *);
|
||||
@@ -4000,7 +4007,7 @@ int uwsgi_is_file2(char *, struct stat *);
|
||||
int uwsgi_is_dir(char *);
|
||||
int uwsgi_is_link(char *);
|
||||
|
||||
void uwsgi_receive_signal(struct wsgi_request *, int, char *, int);
|
||||
int uwsgi_receive_signal(struct wsgi_request *, int, char *, int);
|
||||
void uwsgi_exec_atexit(void);
|
||||
|
||||
struct uwsgi_stats {
|
||||
@@ -4546,6 +4553,7 @@ void uwsgi_master_manage_emperor(void);
|
||||
void uwsgi_master_manage_udp(int);
|
||||
|
||||
void uwsgi_threaded_logger_spawn(void);
|
||||
void uwsgi_threaded_logger_worker_spawn(void);
|
||||
|
||||
void uwsgi_master_check_idle(void);
|
||||
int uwsgi_master_check_workers_deadline(void);
|
||||
|
||||
+8
-4
@@ -1,11 +1,11 @@
|
||||
# uWSGI build system
|
||||
|
||||
uwsgi_version = '2.1'
|
||||
uwsgi_version = '2.1-dev'
|
||||
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
uwsgi_os = os.uname()[0]
|
||||
uwsgi_os = os.environ.get('UWSGI_FORCE_OS', os.uname()[0])
|
||||
uwsgi_os_k = re.split('[-+]', os.uname()[2])[0]
|
||||
uwsgi_os_v = os.uname()[3]
|
||||
uwsgi_cpu = os.uname()[4]
|
||||
@@ -31,7 +31,6 @@ GCC = os.environ.get('CC', sysconfig.get_config_var('CC'))
|
||||
if not GCC:
|
||||
GCC = 'gcc'
|
||||
|
||||
|
||||
def get_preprocessor():
|
||||
if 'clang' in GCC:
|
||||
return 'clang -xc core/clang_fake.c'
|
||||
@@ -810,7 +809,12 @@ class uConf(object):
|
||||
self.libs.append('-lsendfile')
|
||||
self.libs.append('-lrt')
|
||||
self.gcc_list.append('lib/sun_fixes')
|
||||
self.ldflags.append('-L/lib')
|
||||
sunos_major = int(uwsgi_os_k.split('.')[0])
|
||||
sunos_minor = int(uwsgi_os_k.split('.')[1])
|
||||
# solaris < 11 does not have sethostname declared in unistd
|
||||
if not (sunos_major == 5 and sunos_minor > 10):
|
||||
self.cflags.append('-DUWSGI_SUNOS_EXTERN_SETHOSTNAME')
|
||||
self.ldflags.append('-L/lib')
|
||||
if not uwsgi_os_v.startswith('Nexenta'):
|
||||
self.libs.remove('-rdynamic')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user