X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fcluster.pl;h=f1eade415bc263ae5778b03dec2fcf2e8c9ad4f8;hb=4b207544da78b182bd12e94eab01451694749012;hp=3b931a0fba1b8407ee37592d65cd16013e462b27;hpb=c719f7d042e1cc5af74d4c19fc2563de6df7269a;p=spider.git diff --git a/perl/cluster.pl b/perl/cluster.pl index 3b931a0f..f1eade41 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -12,6 +12,17 @@ require 5.004; +package main; + +# set default paths, these should be overwritten by DXVars.pm +use vars qw($data $system $cmd $localcmd $userfn $clusteraddr $clusterport $yes $no $user_interval $lang); + +$lang = 'en'; # default language +$yes = 'Yes'; # visual representation of yes +$no = 'No'; # ditto for no +$user_interval = 11*60; # the interval between unsolicited prompts if no traffic + + # make sure that modules are searched in the order local then perl BEGIN { umask 002; @@ -30,6 +41,11 @@ BEGIN { mkdir "$root/local_cmd", 0777 unless -d "$root/local_cmd"; + $data = "$root/data"; + $system = "$root/sys"; + $cmd = "$root/cmd"; + $localcmd = "$root/local_cmd"; + $userfn = "$data/users"; # try to create and lock a lockfile (this isn't atomic but # should do for now @@ -110,7 +126,6 @@ use Data::Dumper; use IO::File; use Fcntl ':flock'; use POSIX ":sys_wait_h"; -use Version; use Local; @@ -118,12 +133,15 @@ package main; use strict; use vars qw(@inqueue $systime $starttime $lockfn @outstanding_connects - $zombies $root @listeners $lang $myalias @debug $userfn $clusteraddr - $clusterport $mycall $decease $is_win $routeroot $me $reqreg $bumpexisting + $zombies $root @listeners $lang $myalias @debug $userfn + $mycall $decease $is_win $routeroot $me $reqreg $bumpexisting $allowdxby $dbh $dsn $dbuser $dbpass $do_xml $systime_days $systime_daystart $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 @@ -137,6 +155,8 @@ $maxconnect_node = 0; # Ditto but for nodes. In either case if a new incoming # takes the no of references in the routing table above these numbers # then the connection is refused. This only affects INCOMING connections. +use vars qw($version $subversion $build $gitversion $gitbranch); + # send a message to call on conn and disconnect sub already_conn { @@ -300,7 +320,7 @@ sub cease $l->close_server; } - LogDbg('cluster', "DXSpider V$version, build $subversion.$build (git: $gitversion) ended"); + LogDbg('cluster', "DXSpider v$version build $build (git: $gitbranch/$gitversion) using perl $^V on $^O ended"); dbgclose(); Logclose(); @@ -348,6 +368,8 @@ sub AGWrestart # ############################################################# +chdir $root; + $starttime = $systime = time; $systime_days = int ($systime / 86400); $systime_daystart = $systime_days * 86400; @@ -380,23 +402,35 @@ if (DXSql::init($dsn)) { 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 - 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; + } } } } + $SIG{__DIE__} = $w; } @@ -406,7 +440,7 @@ DXXml::init(); # banner my ($year) = (gmtime)[5]; $year += 1900; -LogDbg('cluster', "DXSpider V$version, build $subversion.$build (git: $gitversion) started"); +LogDbg('cluster', "DXSpider v$version build $build (git: $gitbranch/$gitversion) using perl $^V on $^O started"); dbg("Copyright (c) 1998-$year Dirk Koopman G1TLH"); # load Prefixes @@ -423,13 +457,24 @@ Bands::load(); dbg("loading user file system ..."); DXUser->init($userfn, 1); + # look for the sysop and the alias user and complain if they aren't there { die "\$myalias \& \$mycall are the same ($mycall)!, they must be different (hint: make \$mycall = '${mycall}-2';). Oh and don't forget to rerun create_sysop.pl!" if $mycall eq $myalias; my $ref = DXUser::get($mycall); die "$mycall missing, run the create_sysop.pl script and please RTFM" unless $ref && $ref->priv == 9; + my $oldsort = $ref->sort; + if ($oldsort ne 'S') { + $ref->sort('S'); + dbg "Resetting node type from $oldsort -> DXSpider ('S')"; + } $ref = DXUser::get($myalias); die "$myalias missing, run the create_sysop.pl script and please RTFM" unless $ref && $ref->priv == 9; + $oldsort = $ref->sort; + if ($oldsort ne 'U') { + $ref->sort('U'); + dbg "Resetting sysop user type from $oldsort -> User ('U')"; + } } # start listening for incoming messages/connects