support for multiple --touch-reload options

This commit is contained in:
roberto@debian32
2011-10-04 19:40:09 +02:00
parent 702dc44fad
commit 1c0b5b42e9
3 changed files with 19 additions and 16 deletions
+16 -13
View File
@@ -513,16 +513,18 @@ int master_loop(char **argv, char **environ) {
}
}
if (uwsgi.touch_reload) {
struct uwsgi_string_list *touch_reload = uwsgi.touch_reload;
while(touch_reload) {
struct stat tr_st;
if (stat(uwsgi.touch_reload, &tr_st)) {
uwsgi_error("stat()");
uwsgi_log("unable to stat() %s, touch-reload will be disabled\n", uwsgi.touch_reload);
uwsgi.touch_reload = NULL;
if (stat(touch_reload->value, &tr_st)) {
uwsgi_log("unable to stat() %s, reload will be triggered as soon as the file is created\n", touch_reload->value);
touch_reload->custom = 0;
}
else {
uwsgi.last_touch_reload_mtime = tr_st.st_mtime;
touch_reload->custom = (uint64_t) tr_st.st_mtime;
}
touch_reload = touch_reload->next;
}
for (;;) {
@@ -1342,19 +1344,20 @@ healthy:
}
// check touch_reload
if (uwsgi.touch_reload && !uwsgi.to_heaven && !uwsgi.to_hell) {
struct uwsgi_string_list *touch_reload = uwsgi.touch_reload;
while (touch_reload && !uwsgi.to_heaven && !uwsgi.to_hell) {
struct stat tr_st;
if (stat(uwsgi.touch_reload, &tr_st)) {
uwsgi_error("stat()");
uwsgi_log("unable to stat() %s, touch-reload will be disabled\n", uwsgi.touch_reload);
uwsgi.touch_reload = NULL;
if (stat(touch_reload->value, &tr_st)) {
touch_reload->custom = 0;
}
else {
if (tr_st.st_mtime > uwsgi.last_touch_reload_mtime) {
uwsgi_log("*** %s has been touched... grace them all !!! ***\n", uwsgi.touch_reload);
if ((uint64_t)tr_st.st_mtime > touch_reload->custom) {
uwsgi_log("*** %s has been touched... grace them all !!! ***\n", touch_reload->value);
grace_them_all(0);
break;
}
}
touch_reload = touch_reload->next;
}
+1 -1
View File
@@ -3209,7 +3209,7 @@ static int manage_base_opt(int i, char *optarg) {
uwsgi.reload_on_rss = atoi(optarg);
return 1;
case LONG_ARGS_TOUCH_RELOAD:
uwsgi.touch_reload = optarg;
uwsgi_string_new_list(&uwsgi.touch_reload, optarg);
uwsgi.master_process = 1;
return 1;
case LONG_ARGS_PRIO:
+2 -2
View File
@@ -289,6 +289,7 @@ struct uwsgi_string_list {
char *value;
size_t len;
uint64_t custom;
struct uwsgi_string_list *next;
};
@@ -1164,8 +1165,7 @@ struct uwsgi_server {
// funny reload systems
int reload_on_as;
int reload_on_rss;
char *touch_reload;
time_t last_touch_reload_mtime;
struct uwsgi_string_list *touch_reload;
int propagate_touch;