author | Michael Krelin <hacker@klever.net> | 2004-07-24 00:24:07 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2004-07-24 00:24:07 (UTC) |
commit | fbc32792b8d8266ff90aa60403f5da78739236f4 (patch) (side-by-side diff) | |
tree | 77bc3f196a3733c9c86290f8a73d60bb609bbdd5 /src/dudki.cc | |
parent | 125671c860a82643d36bc3da279d0b831fae4b34 (diff) | |
download | dudki-fbc32792b8d8266ff90aa60403f5da78739236f4.zip dudki-fbc32792b8d8266ff90aa60403f5da78739236f4.tar.gz dudki-fbc32792b8d8266ff90aa60403f5da78739236f4.tar.bz2 |
processes specified by process names (pidof-like).
-rw-r--r-- | src/dudki.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/dudki.cc b/src/dudki.cc index 9562079..c966695 100644 --- a/src/dudki.cc +++ b/src/dudki.cc @@ -22,34 +22,36 @@ using namespace std; #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."); restarting = finishing = true; } void check_herd(configuration& config) { + process::prepare_herd(); for(processes_t::iterator i=config.processes.begin();i!=config.processes.end();++i) i->second.check(i->first,config); + process::unprepare_herd(); } void signal_self(const configuration& config,int signum) { ifstream pids(config.pidfile.c_str(),ios::in); if(!pids) throw runtime_error("Can't detect running instance"); pid_t pid = 0; pids >> pid; if(!pid) throw runtime_error("Can't detect running instance"); if(pid==getpid()) throw 0; if(kill(pid,signum)) throw runtime_error("Failed to signal running instance"); } @@ -207,33 +209,36 @@ int main(int argc,char **argv) { config.parse(config_file); switch(op) { case op_test: cerr << "Configuration OK" << endl; break; case op_signal: try { if(optind>=argc) { signal_self(config,op_signum); }else{ int failures = 0; for(int narg=optind;narg<argc;narg++) { try { processes_t::const_iterator i = config.processes.find(argv[narg]); if(i==config.processes.end()) throw runtime_error("no such process configured"); + if(op_signum) i->second.signal(op_signum); + else + i->second.check(); }catch(exception& e) { cerr << "dudki(" << argv[narg] << "): " << e.what() << endl; failures++; } } if(failures) throw runtime_error("not all processes have been successfully signaled"); } if(!op_signum) exit(0); }catch(exception& e) { if(!op_signum) exit(1); } case op_ensure: try { |