summaryrefslogtreecommitdiffabout
path: root/src
authorMichael Krelin <hacker@klever.net>2004-07-21 20:59:33 (UTC)
committer Michael Krelin <hacker@klever.net>2004-07-21 20:59:33 (UTC)
commit4b2d32eca61f62bfd1370fd64254514152ecd23c (patch) (unidiff)
treeab7d32f4b1572a33d1384d3127495feaea3978b4 /src
parent5e437102c59f4544e3803598eabcb643d403272d (diff)
downloaddudki-4b2d32eca61f62bfd1370fd64254514152ecd23c.zip
dudki-4b2d32eca61f62bfd1370fd64254514152ecd23c.tar.gz
dudki-4b2d32eca61f62bfd1370fd64254514152ecd23c.tar.bz2
more civilized restart, bumped up version.
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/dudki.cc5
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;
18#endif 18#endif
19 19
20#define PHEADER PACKAGE " Version " VERSION 20#define PHEADER PACKAGE " Version " VERSION
21#define PCOPY "Copyright (c) 2004 Klever Group" 21#define PCOPY "Copyright (c) 2004 Klever Group"
22 22
23bool finishing = false; 23bool finishing = false;
24bool restarting = false;
24static char **_argv = NULL; 25static char **_argv = NULL;
25 26
26static void lethal_signal_handler(int signum) { 27static void lethal_signal_handler(int signum) {
27 syslog(LOG_NOTICE,"Lethal signal received. Terminating."); 28 syslog(LOG_NOTICE,"Lethal signal received. Terminating.");
28 finishing = true; 29 finishing = true;
29} 30}
30static void sighup_handler(int signum) { 31static void sighup_handler(int signum) {
31 syslog(LOG_NOTICE,"SUGHUP received, reloading."); 32 syslog(LOG_NOTICE,"SUGHUP received, reloading.");
32 execvp(_argv[0],_argv); 33 restarting = finishing = true;
33} 34}
34 35
35void check_herd(configuration& config) { 36void check_herd(configuration& config) {
36 for(processes_t::iterator i=config.processes.begin();i!=config.processes.end();++i) 37 for(processes_t::iterator i=config.processes.begin();i!=config.processes.end();++i)
37 i->second.check(i->first,config); 38 i->second.check(i->first,config);
38} 39}
@@ -234,12 +235,14 @@ int main(int argc,char **argv) {
234 sigaddset(&sset,SIGTERM); sigaddset(&sset,SIGHUP); 235 sigaddset(&sset,SIGTERM); sigaddset(&sset,SIGHUP);
235 sigprocmask(SIG_UNBLOCK,&sset,NULL); 236 sigprocmask(SIG_UNBLOCK,&sset,NULL);
236 while(!finishing) { 237 while(!finishing) {
237 check_herd(config); 238 check_herd(config);
238 sleep(config.check_interval); 239 sleep(config.check_interval);
239 } 240 }
241 if(restarting)
242 execvp(_argv[0],_argv);
240 } 243 }
241 break; 244 break;
242 default: 245 default:
243 throw runtime_error(string(__PRETTY_FUNCTION__)+": internal error"); 246 throw runtime_error(string(__PRETTY_FUNCTION__)+": internal error");
244 } 247 }
245 }catch(exception& e) { 248 }catch(exception& e) {