author | Michael Krelin <hacker@klever.net> | 2004-07-21 20:59:33 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2004-07-21 20:59:33 (UTC) |
commit | 4b2d32eca61f62bfd1370fd64254514152ecd23c (patch) (side-by-side diff) | |
tree | ab7d32f4b1572a33d1384d3127495feaea3978b4 /src | |
parent | 5e437102c59f4544e3803598eabcb643d403272d (diff) | |
download | dudki-4b2d32eca61f62bfd1370fd64254514152ecd23c.zip dudki-4b2d32eca61f62bfd1370fd64254514152ecd23c.tar.gz dudki-4b2d32eca61f62bfd1370fd64254514152ecd23c.tar.bz2 |
more civilized restart, bumped up version.
-rw-r--r-- | src/dudki.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/dudki.cc b/src/dudki.cc index b769109..b4e95a7 100644 --- a/src/dudki.cc +++ b/src/dudki.cc @@ -18,21 +18,22 @@ using namespace std; #endif #define PHEADER PACKAGE " Version " VERSION #define PCOPY "Copyright (c) 2004 Klever Group" bool finishing = false; +bool restarting = false; static char **_argv = NULL; static void lethal_signal_handler(int signum) { syslog(LOG_NOTICE,"Lethal signal received. Terminating."); finishing = true; } static void sighup_handler(int signum) { syslog(LOG_NOTICE,"SUGHUP received, reloading."); - execvp(_argv[0],_argv); + restarting = finishing = true; } void check_herd(configuration& config) { for(processes_t::iterator i=config.processes.begin();i!=config.processes.end();++i) i->second.check(i->first,config); } @@ -234,12 +235,14 @@ int main(int argc,char **argv) { sigaddset(&sset,SIGTERM); sigaddset(&sset,SIGHUP); sigprocmask(SIG_UNBLOCK,&sset,NULL); while(!finishing) { check_herd(config); sleep(config.check_interval); } + if(restarting) + execvp(_argv[0],_argv); } break; default: throw runtime_error(string(__PRETTY_FUNCTION__)+": internal error"); } }catch(exception& e) { |