From d5210283caa3473c7505c41057590bc8d3a5136e Mon Sep 17 00:00:00 2001 From: "roberto@maverick64" Date: Sun, 3 Jul 2011 19:16:09 +0200 Subject: [PATCH] launch stop hook on emperor quit --- emperor.c | 70 ++++++++++++++++++++++++++++++-------------------- vassals/cc.ini | 2 +- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/emperor.c b/emperor.c index 79aac565..61058804 100644 --- a/emperor.c +++ b/emperor.c @@ -8,40 +8,54 @@ extern char **environ; int emperor_queue; char *emperor_absolute_dir; +struct uwsgi_instance { + struct uwsgi_instance *ui_prev; + struct uwsgi_instance *ui_next; + + char name[0xff]; + pid_t pid; + + int status; + time_t born; + time_t last_mod; + time_t last_loyal; + + uint64_t respawns; + int use_config; + + int pipe[2]; + int pipe_config[2]; + + char *config; + uint32_t config_len; + + int loyal; + + int zerg; +}; + + +struct uwsgi_instance *ui; + static void royal_death(int signum) { + + + if (uwsgi.vassals_stop_hook) { + + struct uwsgi_instance *c_ui = ui->ui_next; + + while (c_ui) { + uwsgi_log("running vassal stop-hook: %s %s\n", uwsgi.vassals_stop_hook, c_ui->name); + int stop_hook_ret = uwsgi_run_command_and_wait(uwsgi.vassals_stop_hook, c_ui->name); + uwsgi_log("%s stop-hook returned %d\n", c_ui->name, stop_hook_ret); + c_ui = c_ui->ui_next; + } + } uwsgi_notify("The Emperor is buried."); exit(0); } -struct uwsgi_instance { - struct uwsgi_instance *ui_prev; - struct uwsgi_instance *ui_next; - - char name[0xff]; - pid_t pid; - - int status; - time_t born; - time_t last_mod; - time_t last_loyal; - - uint64_t respawns; - int use_config; - - int pipe[2]; - int pipe_config[2]; - - char *config; - uint32_t config_len; - - int loyal; - - int zerg; -}; - -struct uwsgi_instance *ui; - void emperor_stats() { struct uwsgi_instance *c_ui = ui->ui_next; diff --git a/vassals/cc.ini b/vassals/cc.ini index 12f6f3ac..02d0c586 100644 --- a/vassals/cc.ini +++ b/vassals/cc.ini @@ -3,7 +3,7 @@ trac = trac.web.main id = myapp socket = /tmp/%(id).sock -socket = :3031 +socket = :0 env = TRAC_ENV=/opt/projects/%(id) module = %(trac):dispatch_request processes = 8