Write pidfile and pidfile2 only after successful start

This commit is contained in:
Janos Guljas
2014-12-23 15:39:19 +01:00
parent b59294db89
commit d79eeefe97
3 changed files with 15 additions and 8 deletions
+7
View File
@@ -3587,6 +3587,13 @@ void uwsgi_write_pidfile(char *pidfile_name) {
}
}
void uwsgi_write_pidfile_explicit(char *pidfile_name, pid_t pid) {
uwsgi_log("writing pidfile to %s\n", pidfile_name);
if (uwsgi_write_intfile(pidfile_name, (int) pid)) {
uwsgi_log("could not write pidfile.\n");
}
}
char *uwsgi_expand_path(char *dir, int dir_len, char *ptr) {
char src[PATH_MAX + 1];
memcpy(src, dir, dir_len);
+7 -8
View File
@@ -2420,10 +2420,6 @@ configure:
uwsgi_log("*** running under screen session %s ***\n", uwsgi.screen_session);
}
if (uwsgi.pidfile && !uwsgi.is_a_reload) {
uwsgi_write_pidfile(uwsgi.pidfile);
}
uwsgi_log_initial("detected binary path: %s\n", uwsgi.binary_path);
if (uwsgi.is_a_reload) {
@@ -2523,6 +2519,10 @@ configure:
#if defined(__linux__) && !defined(__ia64__)
}
#endif
if (uwsgi.pidfile && !uwsgi.is_a_reload) {
uwsgi_write_pidfile_explicit(uwsgi.pidfile, masterpid);
}
}
@@ -2595,10 +2595,6 @@ int uwsgi_start(void *v_argv) {
}
}
if (uwsgi.pidfile2 && !uwsgi.is_a_reload) {
uwsgi_write_pidfile(uwsgi.pidfile2);
}
if (!uwsgi.master_process && !uwsgi.command_mode) {
uwsgi_log_initial("*** WARNING: you are running uWSGI without its master process manager ***\n");
}
@@ -3258,6 +3254,9 @@ next2:
}
}
if (uwsgi.pidfile2 && !uwsgi.is_a_reload) {
uwsgi_write_pidfile_explicit(uwsgi.pidfile2, masterpid);
}
// END OF INITIALIZATION
return 0;
+1
View File
@@ -3958,6 +3958,7 @@ void uwsgi_setup_post_buffering(void);
struct uwsgi_lock_item *uwsgi_lock_ipcsem_init(char *);
void uwsgi_write_pidfile(char *);
void uwsgi_write_pidfile_explicit(char *, pid_t);
int uwsgi_write_intfile(char *, int);
void uwsgi_protected_close(int);