flush logs on exit

This commit is contained in:
roberto@precise64
2012-02-23 07:48:54 +01:00
parent 7329606a6a
commit 3787d5e84a
3 changed files with 24 additions and 3 deletions
+3 -3
View File
@@ -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;
}
}
+19
View File
@@ -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);
+2
View File
@@ -2647,6 +2647,8 @@ int uwsgi_calc_cheaper(void);
int uwsgi_cheaper_algo_spare(void);
int uwsgi_cheaper_algo_backlog(void);
void uwsgi_master_log(void);
#ifdef UWSGI_AS_SHARED_LIBRARY
int uwsgi_init(int, char **, char **);
#endif