mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-10-03 15:38:36 +00:00
flush logs on exit
This commit is contained in:
@@ -68,7 +68,7 @@ void expire_rb_timeouts(struct rb_root *root) {
|
||||
}
|
||||
}
|
||||
|
||||
void master_log(void) {
|
||||
void uwsgi_master_log(void) {
|
||||
|
||||
char log_buf[4096];
|
||||
|
||||
@@ -99,7 +99,7 @@ void *logger_thread_loop(void *noarg) {
|
||||
int ret = poll(&logpoll, 1, -1);
|
||||
if (ret > 0 && logpoll.revents & POLLIN) {
|
||||
pthread_mutex_lock(&uwsgi.threaded_logger_lock);
|
||||
master_log();
|
||||
uwsgi_master_log();
|
||||
pthread_mutex_unlock(&uwsgi.threaded_logger_lock);
|
||||
}
|
||||
}
|
||||
@@ -777,7 +777,7 @@ int master_loop(char **argv, char **environ) {
|
||||
|
||||
if (uwsgi.log_master && !uwsgi.threaded_logger) {
|
||||
if (interesting_fd == uwsgi.shared->worker_log_pipe[0]) {
|
||||
master_log();
|
||||
uwsgi_master_log();
|
||||
goto health_cycle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1118,6 +1118,24 @@ void uwsgi_fpe(int signum) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void uwsgi_flush_logs() {
|
||||
|
||||
struct pollfd pfd;
|
||||
|
||||
if (!uwsgi.workers) return;
|
||||
if (!uwsgi.master_process) return;
|
||||
if (!uwsgi.log_master) return;
|
||||
|
||||
if (getpid() == uwsgi.workers[0].pid) {
|
||||
// check for data in logpipe
|
||||
pfd.events = POLLIN;
|
||||
pfd.fd = uwsgi.shared->worker_log_pipe[0];
|
||||
while(poll(&pfd, 1, 0) > 0) {
|
||||
uwsgi_master_log();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef UWSGI_AS_SHARED_LIBRARY
|
||||
int uwsgi_init(int argc, char *argv[], char *envp[]) {
|
||||
@@ -1170,6 +1188,7 @@ int main(int argc, char *argv[], char *envp[]) {
|
||||
init_magic_table(uwsgi.magic_table);
|
||||
|
||||
atexit(vacuum);
|
||||
atexit(uwsgi_flush_logs);
|
||||
atexit(uwsgi_plugins_atexit);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user