X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fcluster.pl;h=cc96ac59b0bf065e2bff69cdd9aa5ba0db5825fa;hb=770092d94f96b6d22a38fb33e0056b4779a8a1ab;hp=7436c874dfed6770c9add6812d71cfd49ee38959;hpb=58dc48be20833f4a2754b540f82c5a764fcb73ac;p=spider.git diff --git a/perl/cluster.pl b/perl/cluster.pl index 7436c874..cc96ac59 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -18,8 +18,6 @@ package main; use vars qw($data $system $cmd $localcmd $userfn $clusteraddr $clusterport $yes $no $user_interval $lang); $lang = 'en'; # default language -$clusteraddr = '127.0.0.1'; # cluster tcp host address - used for things like console.pl -$clusterport = 27754; # cluster tcp port $yes = 'Yes'; # visual representation of yes $no = 'No'; # ditto for no $user_interval = 11*60; # the interval between unsolicited prompts if no traffic @@ -123,6 +121,7 @@ use DXXml; use DXSql; use IsoTime; use BPQMsg; +use DXCIDR; use Data::Dumper; use IO::File; @@ -141,6 +140,9 @@ use vars qw(@inqueue $systime $starttime $lockfn @outstanding_connects $can_encode $maxconnect_user $maxconnect_node ); + +$clusteraddr ||= '127.0.0.1'; # cluster tcp host address - used for things like console.pl +$clusterport ||= 27754; # cluster tcp port @inqueue = (); # the main input queue, an array of hashes $systime = 0; # the time now (in seconds) $starttime = 0; # the starting time of the cluster @@ -270,10 +272,16 @@ sub login } # cease running this program, close down all the connections nicely +our $is_ceasing; + sub cease { my $dxchan; + cluck("ceasing") if $is_ceasing; + + return if $is_ceasing++; + unless ($is_win) { $SIG{'TERM'} = 'IGNORE'; $SIG{'INT'} = 'IGNORE'; @@ -292,13 +300,14 @@ sub cease foreach $dxchan (DXChannel::get_all_nodes) { $dxchan->disconnect(2) unless $dxchan == $main::me; } - Msg->event_loop(100, 0.01); # disconnect users foreach $dxchan (DXChannel::get_all_users) { $dxchan->disconnect; } + Msg->event_loop(100, 0.01); + # disconnect AGW AGWMsg::finish(); BPQMsg::finish(); @@ -308,8 +317,9 @@ sub cease # end everything else Msg->event_loop(100, 0.01); - DXUser::finish(); DXDupe::finish(); + QSL::finish(); + DXUser::finish(); # close all databases DXDb::closeall; @@ -319,12 +329,12 @@ sub cease $l->close_server; } - LogDbg('cluster', "DXSpider V$version build $build (git: $gitbranch/$gitversion) on $^O ended"); + $dbh->finish if $dbh; + + LogDbg("DXSpider v$version build $build (git: $gitbranch/$gitversion) using perl $^V on $^O ended"); dbgclose(); Logclose(); - $dbh->finish if $dbh; - unlink $lockfn; # $SIG{__WARN__} = $SIG{__DIE__} = sub {my $a = shift; cluck($a); }; exit(0); @@ -407,7 +417,7 @@ if (DXSql::init($dsn)) { # determine the real Git build number and branch my $desc; - eval {$desc = `git -C $root describe --long`}; + eval {$desc = `git --git-dir=$root/.git describe --long`}; if (!$@ && $desc) { my ($v, $s, $b, $g) = $desc =~ /^([\d\.]+)(?:\.(\d+))?-(\d+)-g([0-9a-f]+)/; $version = $v; @@ -418,7 +428,7 @@ if (DXSql::init($dsn)) { if (!$@) { my @branch; - eval {@branch = `git -C $root branch`}; + eval {@branch = `git --git-dir=$root/.git branch`}; unless ($@) { for (@branch) { my ($star, $b) = split /\s+/; @@ -439,8 +449,9 @@ DXXml::init(); # banner my ($year) = (gmtime)[5]; $year += 1900; -LogDbg('cluster', "DXSpider V$version build $build (git: $gitbranch/$gitversion) on $^O started"); -dbg("Copyright (c) 1998-$year Dirk Koopman G1TLH"); +LogDbg('cluster', "DXSpider v$version build $build (git: $gitbranch/$gitversion) using perl $^V on $^O started"); +LogDbg('cluster', "Copyright (c) 1998-$year Dirk Koopman G1TLH"); +LogDbg('cluster', "Capabilities: ve7cc rbn"); # load Prefixes dbg("loading prefixes ..."); @@ -476,6 +487,9 @@ DXUser->init($userfn, 1); } } +# get any bad IPs +DXCIDR::init(); + # start listening for incoming messages/connects dbg("starting listeners ..."); my $conn = IntMsg->new_server($clusteraddr, $clusterport, \&login); @@ -641,7 +655,12 @@ for (;;) { last if --$decease <= 0; } } -cease(0); +cease(0) unless $is_ceasing; exit(0); +# +sub END +{ + cease(0) unless $is_ceasing; +}