Tue Jan 25 21:18:48 PST 2005
- Previous message: [Slony1-general] Updated RPM build patch
- Next message: [Slony1-general] Re: [patch] Adding --config to slon_watchdog.pl
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
slon_watchdog.pl.diff - Added --config and --help options, as with other files - Use a while loop instead of a recursive function for the watchdog process - Allow node# to be given as just a number, as with other files slon_start.pl.diff - --help would fail if --config wasn't specified and slon.env wasn't in @INC - Call slon_watchdog.pl using --config -- Steve Simms <steve at deefs.net> http://www.deefs.net -------------- next part -------------- Index: slon_start.pl =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slon_start.pl,v retrieving revision 1.6 diff -u -3 -r1.6 slon_start.pl --- slon_start.pl 4 Jan 2005 22:26:38 -0000 1.6 +++ slon_start.pl 25 Jan 2005 21:03:30 -0000 @@ -17,9 +17,6 @@ "sleep=i" => \$SLEEP_TIME, "help" => \$SHOW_USAGE); -require 'slon-tools.pm'; -require $SLON_ENV_FILE; - my $USAGE = "Usage: slon_start.pl [--config file] [--watchdog|--nowatchdog] [--sleep seconds] node# @@ -40,6 +37,9 @@ die $USAGE; } +require 'slon-tools.pm'; +require $SLON_ENV_FILE; + $node = $ARGV[0]; # Node can be passed either as "node1" or just "1" @@ -67,6 +67,6 @@ print "PID [$pid]\n"; if ($START_WATCHDOG) { print "Start the watchdog process as well...\n"; - system "perl slon_watchdog.pl $node $SLEEP_TIME &"; + system "perl slon_watchdog.pl --config=$SLON_ENV_FILE $node $SLEEP_TIME &"; } } -------------- next part -------------- Index: slon_watchdog.pl =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slon_watchdog.pl,v retrieving revision 1.3 diff -u -3 -r1.3 slon_watchdog.pl --- slon_watchdog.pl 9 Sep 2004 17:04:08 -0000 1.3 +++ slon_watchdog.pl 25 Jan 2005 21:05:04 -0000 @@ -3,24 +3,43 @@ # Author: Christopher Browne # Copyright 2004 Afilias Canada -require 'slon-tools.pm'; -require 'slon.env'; +use Getopt::Long; + +# Defaults +$SLON_ENV_FILE = 'slon.env'; # Where to find the slon.env file +$SHOW_USAGE = 0; # Show usage, then quit + +# Read command-line options +GetOptions("config=s" => \$SLON_ENV_FILE, + "help" => \$SHOW_USAGE); + +my $USAGE = +"Usage: slon_watchdog.pl [--config file] node# sleep_seconds + + --config file Location of the slon.env file (default: Perl's \@INC) -$node =$ARGV[0]; -$sleep =$ARGV[1]; + sleep_seconds Number of seconds for the watchdog process to sleep + between checks -if ( scalar(@ARGV) < 2 ) { - die "Usage: ./slon_watchdog node sleep-time\n"; +"; + +if ($SHOW_USAGE or scalar(@ARGV) != 2) { + die $USAGE; } -if ($node =~/^node(\d+)$/) { +require 'slon-tools.pm'; +require $SLON_ENV_FILE; + +$node = $ARGV[0]; +$sleep = $ARGV[1]; + +if ($node =~/^(?:node)?(\d+)$/) { $nodenum = $1; +} else { + die $USAGE; } -slon_watchdog($node, $nodenum); - -sub slon_watchdog { - my ($node, $nodenum) = @_; +while (1) { $pid = get_pid($node); if (!($pid)) { my ($dsn, $dbname) = ($DSN[$nodenum], $DBNAME[$nodenum]); @@ -44,5 +63,4 @@ } close(PSOUT); sleep $sleep; - slon_watchdog(); }
- Previous message: [Slony1-general] Updated RPM build patch
- Next message: [Slony1-general] Re: [patch] Adding --config to slon_watchdog.pl
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-general mailing list