#!/usr/bin/perl ###################################################################### # General use and inits ###################################################################### # Standard CPAN modules use POSIX; use Carp; # Home Grown use vgapas; # containing GenericDB and others use TEST; use strict; my $time_to_die = 0; # I omitted the SIG handlers here my $dbq; ###################################################################### # # call_host # ###################################################################### sub call_host { my $tag = shift; my $sql = qq/SELECT number,trncnt,status FROM positions WHERE tag = '$tag' AND status != 'D'/; foreach my $gr (@{$dbq->fetchall($sql)}) { # stuph } # more stuph &remote_exported_sub($tag); } ###################################################################### # # wakeup # ###################################################################### sub wakeup { # Object to DB handle $dbq = vgapas::GenericDB->new(); unless (ref $dbq) { print "dbq is not a ref in wakeup\n"; exit(1); } my $sql = qq/SELECT tag,name,schedule,next FROM games WHERE active = 'Y'/; foreach my $rr (@{$dbq->fetchall($sql)}) { if (#condition) { &call_host($rr->[0]); } } } ###################################################################### # # MAIN # ###################################################################### # Fork into background my $pid; if ($pid = fork) { # Mark startup my $pt = localtime(); print "$0 start: pid = $pid\n"; } elsif (defined $pid) { # Detach and set up loop POSIX::setsid() || croak "Can't start a new session: $!\n"; until ($time_to_die) { &wakeup(); sleep(300); } } else { print "Unable to Fork: $!\n"; }