X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fcluster.pl;h=4222132c2b982bee9fe2490d99cab9ca184ab224;hb=8d4360134b5a83741dbd77ef99a56c2f1c40db05;hp=d82dd2e73bbd8d67aa68538a39dd19e49f6ae00e;hpb=4f1c00b0c181d994b13bb9b0ff9ea03ee0cf120c;p=spider.git diff --git a/perl/cluster.pl b/perl/cluster.pl index d82dd2e7..4222132c 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -135,7 +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 + $broadcast_debug ); @inqueue = (); # the main input queue, an array of hashes @@ -155,6 +155,8 @@ $log_flush_interval = 2; # interval to wait between log flushes our $ending; # signal that we are ending; our $broadcast_debug; # allow broadcasting of debug info down "enhanced" user connections +our $clssecs; # the amount of cpu time the DXSpider process have consumed +our $cldsecs; # the amount of cpu time any child processes have consumed # send a message to call on conn and disconnect @@ -350,77 +352,6 @@ sub AGWrestart AGWMsg::init(\&new_channel); } -our $io_disconnected; - -sub idle_loop -{ - my $timenow = time; - - BPQMsg::process(); -# DXChannel::process(); - - # $DB::trace = 0; - - # do timed stuff, ongoing processing happens one a second - if ($timenow != $systime) { - reap() if $zombies; - $systime = $timenow; - my $days = int ($systime / 86400); - if ($systime_days != $days) { - $systime_days = $days; - $systime_daystart = $days * 86400; - } - IsoTime::update($systime); - DXCron::process(); # do cron jobs - DXCommandmode::process(); # process ongoing command mode stuff - DXXml::process(); - DXProt::process(); # process ongoing ak1a pcxx stuff - DXConnect::process(); - DXMsg::process(); - DXDb::process(); - DXUser::process(); - DXDupe::process(); - DXCron::process(); # do cron jobs - IsoTime::update($systime); - DXProt::process(); # process ongoing ak1a pcxx stuff - DXConnect::process(); - DXUser::process(); - AGWMsg::process(); - - Timer::handler(); - DXLog::flushall(); - } - - if (defined &Local::process) { - eval { - Local::process(); # do any localised processing - }; - dbg("Local::process error $@") if $@; - } - - while ($ending) { - my $dxchan; - - dbg("DXSpider Ending $ending"); - - unless ($io_disconnected++) { - - # disconnect users - foreach $dxchan (DXChannel::get_all_users) { - $dxchan->disconnect; - } - - # disconnect nodes - foreach $dxchan (DXChannel::get_all_nodes) { - next if $dxchan == $main::me; - $dxchan->disconnect(2); - } - $main::me->disconnect; - } - - Mojo::IOLoop->stop if --$ending <= 0; - } -} sub setup_start { @@ -646,11 +577,112 @@ sub setup_start #open(DB::OUT, "|tee /tmp/aa"); } +our $io_disconnected; + +sub idle_loop +{ + BPQMsg::process(); + + if (defined &Local::process) { + eval { + Local::process(); # do any localised processing + }; + dbg("Local::process error $@") if $@; + } + + while ($ending) { + my $dxchan; + + dbg("DXSpider Ending $ending"); + + unless ($io_disconnected++) { + + # disconnect users + foreach $dxchan (DXChannel::get_all_users) { + $dxchan->disconnect; + } + + # disconnect nodes + foreach $dxchan (DXChannel::get_all_nodes) { + next if $dxchan == $main::me; + $dxchan->disconnect(2); + } + $main::me->disconnect; + } + + Mojo::IOLoop->stop if --$ending <= 0; + } +} + +sub per_sec +{ + my $timenow = time; + + reap() if $zombies; + $systime = $timenow; + my $days = int ($systime / 86400); + if ($systime_days != $days) { + $systime_days = $days; + $systime_daystart = $days * 86400; + } + IsoTime::update($systime); + DXCron::process(); # do cron jobs + DXCommandmode::process(); # process ongoing command mode stuff + DXXml::process(); + DXProt::process(); # process ongoing ak1a pcxx stuff + DXConnect::process(); + DXMsg::process(); + DXDb::process(); + DXUser::process(); + DXDupe::process(); + DXCron::process(); # do cron jobs + IsoTime::update($systime); + DXProt::process(); # process ongoing ak1a pcxx stuff + DXConnect::process(); + DXUser::process(); + AGWMsg::process(); + + Timer::handler(); + DXLog::flushall(); +} + +sub per_10_sec +{ + +} + + +sub per_minute +{ + +} + +sub per_10_minute +{ + +} + +sub per_hour +{ + +} + +sub per_day +{ + +} setup_start(); my $main_loop = Mojo::IOLoop->recurring($idle_interval => \&idle_loop); my $log_flush_loop = Mojo::IOLoop->recurring($log_flush_interval => \&DXLog::flushall); +my $cpusecs_loop = Mojo::IOLoop->recurring(5 => sub {my @t = times; $clssecs = $t[0]+$t[1]; $cldsecs = $t[2]+$t[3]}); +my $persec = Mojo::IOLoop->recurring(1 => \&per_sec); +my $per10sec = Mojo::IOLoop->recurring(10 => \&per_10_sec); +my $permin = Mojo::IOLoop->recurring(60 => \&per_minute); +my $per10min = Mojo::IOLoop->recurring(600 => \&per_10_minute); +my $perhour = Mojo::IOLoop->recurring(3600 => \&per_hour); +my $perday = Mojo::IOLoop->recurring(86400 => \&per_day); Web::start_node();