X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=perl%2Fcluster.pl;h=d82dd2e73bbd8d67aa68538a39dd19e49f6ae00e;hb=7b8a8931b9fe531868777d5168b9a35baf37f0d9;hp=55841c2f826e1c737c32838ed1ab5510f59ca54a;hpb=e91eba286b10ba045c7a41cb483f80bab4c0ac3b;p=spider.git diff --git a/perl/cluster.pl b/perl/cluster.pl index 55841c2f..d82dd2e7 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl # # This is the DX cluster 'daemon'. It sits in the middle of its little # web of client routines sucking and blowing data where it may. @@ -10,7 +10,10 @@ # # +package main; + require 5.10.1; +use warnings; # make sure that modules are searched in the order local then perl BEGIN { @@ -28,18 +31,22 @@ BEGIN { die "$root/local doesn't exist, please RTFM" unless -d "$root/local"; die "$root/local/DXVars.pm doesn't exist, please RTFM" unless -e "$root/local/DXVars.pm"; - mkdir "$root/local_cmd", 0777 unless -d "$root/local_cmd"; - + # create some directories + mkdir "$root/local_cmd", 02777 unless -d "$root/local_cmd"; + mkdir "$root/local_data", 02777 unless -d "$root/local_data"; # try to create and lock a lockfile (this isn't atomic but # should do for now - $lockfn = "$root/local/cluster.lck"; # lock file name + $lockfn = "$root/local_data/cluster.lck"; # lock file name if (-w $lockfn) { open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!"; my $pid = ; if ($pid) { chomp $pid; - die "Lockfile ($lockfn) and process $pid exist, another cluster running?" if kill 0, $pid; + if (kill 0, $pid) { + warn "Lockfile ($lockfn) and process $pid exist, another cluster running?\n"; + exit 1; + } } unlink $lockfn; close CLLOCK; @@ -52,9 +59,12 @@ BEGIN { $systime = time; } + use Mojo::IOLoop; use DXVars; +use SysVar; + use Msg; use IntMsg; use Internet; @@ -125,6 +135,7 @@ use vars qw(@inqueue $systime $starttime $lockfn @outstanding_connects $clusterport $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 $idle_interval $log_flush_interval + $broadcast_debug ); @inqueue = (); # the main input queue, an array of hashes @@ -142,7 +153,8 @@ $maxconnect_node = 0; # Ditto but for nodes. In either case if a new incoming $idle_interval = 0.500; # the wait between invocations of the main idle loop processing. $log_flush_interval = 2; # interval to wait between log flushes -our $ending; # signal that we are ending; +our $ending; # signal that we are ending; +our $broadcast_debug; # allow broadcasting of debug info down "enhanced" user connections # send a message to call on conn and disconnect @@ -429,12 +441,13 @@ sub setup_start } # open the debug file, set various FHs to be unbuffered - dbginit(\&DXCommandmode::broadcast_debug); + dbginit($broadcast_debug ? \&DXCommandmode::broadcast_debug : undef); foreach (@debug) { dbgadd($_); } STDOUT->autoflush(1); + # try to load the database if (DXSql::init($dsn)) { $dbh = DXSql->new($dsn); @@ -491,15 +504,25 @@ sub setup_start # initialise User file system dbg("loading user file system ..."); - DXUser->init($userfn, 1); + DXUser::init(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