From 33b736289ace0927c4ac2478d23d878c583307cb Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Thu, 13 Jun 2002 16:49:02 +0000 Subject: Catch sigs --- pingd | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'pingd') diff --git a/pingd b/pingd index 2b4660a..44a323b 100755 --- a/pingd +++ b/pingd @@ -1,14 +1,14 @@ #!/usr/bin/perl -wT # (c) 2002 Peter Palfrader -# $Id: pingd,v 1.3 2002/06/11 10:10:34 weasel Exp $ +# $Id: pingd,v 1.4 2002/06/13 16:49:02 weasel Exp $ # use strict; use XML::Parser; use XML::Dumper; use Getopt::Long; -use lib '.'; +use lib qw{ . lib }; use Echolot::Config; use Echolot::Globals; use Echolot::Storage::File; @@ -16,21 +16,48 @@ use Echolot::Scheduler; use Echolot::Conf; use Echolot::Mailin; use Echolot::Pinger; +use Echolot::Stats; $ENV{'PATH'} = '/bin:/usr/bin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; +$SIG{'INT'} = sub { + print "Got SIGINT. committ()ing\n"; + Echolot::Globals::get()->{'storage'}->commit(); + Echolot::Globals::get()->{'storage'}->finish(); + exit 0; +}; +$SIG{'QUIT'} = sub { + print "Got SIGQUIT. committ()ing\n"; + Echolot::Globals::get()->{'storage'}->commit(); + Echolot::Globals::get()->{'storage'}->finish(); + exit 0; +}; +$SIG{'TERM'} = sub { + print "Got SIGTERM. committ()ing\n"; + Echolot::Globals::get()->{'storage'}->commit(); + Echolot::Globals::get()->{'storage'}->finish(); + exit 0; +}; + + Echolot::Config::init(); Echolot::Globals::init(); my $scheduler = new Echolot::Scheduler; $scheduler->add('processmail' , 60 , 0, \&Echolot::Mailin::process ); -$scheduler->add('getkeyconf' , 10*60 , 0, \&Echolot::Conf::send_requests ); +$scheduler->add('getkeyconf' , 3*60 , 0, \&Echolot::Conf::send_requests ); $scheduler->add('ping' , Echolot::Config::get()->{'pinger_interval'}, 0, \&Echolot::Pinger::send_pings ); +$scheduler->add('buildstats' , 60 , 0, \&Echolot::Stats::build ); $scheduler->run(); +#Echolot::Mailin::process(); +#Echolot::Conf::send_requests(); +#Echolot::Stats::build(); -#Echolot::Globals::get()->{'storage'}->commit(); +Echolot::Globals::get()->{'storage'}->commit(); +Echolot::Globals::get()->{'storage'}->finish(); +exit 0; # vim: set ts=4 shiftwidth=4: -- cgit v1.2.3