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
use DXSql;
use IsoTime;
use BPQMsg;
+use DXCIDR;
use Data::Dumper;
use IO::File;
$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
}
# 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';
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();
# end everything else
Msg->event_loop(100, 0.01);
- DXUser::finish();
DXDupe::finish();
+ QSL::finish();
+ DXUser::finish();
# close all databases
DXDb::closeall;
$l->close_server;
}
- LogDbg('cluster', "DXSpider V$version, build $subversion.$build (git: $gitbranch/$gitversion) 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);
#
#############################################################
+chdir $root;
+
$starttime = $systime = time;
$systime_days = int ($systime / 86400);
$systime_daystart = $systime_days * 86400;
import Encode;
$can_encode = 1;
}
- eval { require Git; };
- unless ($@) {
- import Git;
+
+ $gitbranch = 'none';
+ $gitversion = 'none';
+
+ # determine the real Git build number and branch
+ my $desc;
+ 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;
+ $subversion = $s || 0;
+ $build = $b || 0;
+ $gitversion = "$g\[r]";
+ }
+ if (!$@) {
+ my @branch;
- # determine the real version number
- $gitbranch = 'none';
- $gitversion = 'none';
- my $repo = Git->repository(Directory => "$root/.git");
- if ($repo) {
- my $desc = $repo->command_oneline(['describe'], STDERR => 0);
- if ($desc) {
- my ($v, $s, $b, $g) = $desc =~ /^([\d.]+)(?:\.(\d+))?-(\d+)-g([0-9a-f]+)/;
- $version = $v;
- $subversion = $s || 0;
- $build = $b || 0;
- $gitversion = "$g\[r]";
+ eval {@branch = `git --git-dir=$root/.git branch`};
+ unless ($@) {
+ for (@branch) {
+ my ($star, $b) = split /\s+/;
+ if ($star eq '*') {
+ $gitbranch = $b;
+ last;
+ }
}
}
- my @branch = $repo->command([qw{branch}], STDERR=>0);
- for (@branch) {
- my ($star, $b) = split /\s+/;
- if ($star eq '*') {
- $gitbranch = $b;
- last;
- }
- }
-
}
+
$SIG{__DIE__} = $w;
}
# banner
my ($year) = (gmtime)[5];
$year += 1900;
-LogDbg('cluster', "DXSpider V$version, build $subversion.$build (git: $gitbranch/$gitversion) 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 ...");
}
}
+# get any bad IPs
+DXCIDR::init();
+
# start listening for incoming messages/connects
dbg("starting listeners ...");
my $conn = IntMsg->new_server($clusteraddr, $clusterport, \&login);
last if --$decease <= 0;
}
}
-cease(0);
+cease(0) unless $is_ceasing;
exit(0);
+#
+sub END
+{
+ cease(0) unless $is_ceasing;
+}