summaryrefslogtreecommitdiff
path: root/pingd
blob: 44a323b705da561e5e48fb9d0bf98f8dfa8dd596 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl -wT

# (c) 2002 Peter Palfrader <peter@palfrader.org>
# $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 qw{ . lib };
use Echolot::Config;
use Echolot::Globals;
use Echolot::Storage::File;
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'  ,   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'}->finish();
exit 0;

# vim: set ts=4 shiftwidth=4: