Tue Jan 4 22:26:41 PST 2005
- Previous message: [Slony1-commit] By cbbrowne: Add in support for SSL connections Thanks to Steve Simms
- Next message: [Slony1-commit] By cbbrowne: Some fixes to spelling in comments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Log Message:
-----------
Add in startup script changes from Steve Simms...
- Support long option names
- Optionally don't start a watchdog
- Optionally specify where slon.env is
- Nodes can be specified in either the form "node123" or "123"
Modified Files:
--------------
slony1-engine/tools/altperl:
slon_start.pl (r1.5 -> r1.6)
-------------- next part --------------
Index: slon_start.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slon_start.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -Ltools/altperl/slon_start.pl -Ltools/altperl/slon_start.pl -u -w -r1.5 -r1.6
--- tools/altperl/slon_start.pl
+++ tools/altperl/slon_start.pl
@@ -1,44 +1,72 @@
-#!perl # -*- perl -*-
+#!/usr/bin/perl
# $Id$
# Author: Christopher Browne
# Copyright 2004 Afilias Canada
-#start the slon daemon
+use Getopt::Long;
+
+# Defaults
+$START_WATCHDOG = 1; # Whether or not the watchdog process should be started
+$SLEEP_TIME = 30; # Number of seconds for watchdog to sleep
+$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,
+ "watchdog!" => \$START_WATCHDOG,
+ "sleep=i" => \$SLEEP_TIME,
+ "help" => \$SHOW_USAGE);
+
require 'slon-tools.pm';
-require 'slon.env';
-$SLEEPTIME=30; # number of seconds for watchdog to sleep
+require $SLON_ENV_FILE;
-$node =$ARGV[0];
+my $USAGE =
+"Usage: slon_start.pl [--config file] [--watchdog|--nowatchdog]
+ [--sleep seconds] node#
+
+ --config file Location of the slon.env file (default: Perl's \@INC)
+
+ --watchdog Start a watchdog process after starting the slon
+ daemon (default)
+
+ --nowatchdog Do not start a watchdog process
+
+ --sleep seconds Number of seconds for the watchdog process to sleep
+ between checks (default 30)
-if ( scalar(@ARGV) < 1 ) {
- die "Usage: ./slon_start [node]\n";
+";
+
+if ($SHOW_USAGE or scalar(@ARGV) != 1) {
+ die $USAGE;
}
-if ($node =~ /^node(\d+)$/) {
- # Node name is in proper form
+$node = $ARGV[0];
+
+# Node can be passed either as "node1" or just "1"
+if ($node =~ /^(?:node)?(\d+)$/) {
+ $node = "node$1";
$nodenum = $1;
} else {
- print "Valid node names are node1, node2, ...\n\n";
- die "Usage: ./slon_start [node]\n";
+ die $USAGE;
}
$pid = get_pid($node);
-
if ($pid) {
- die "Slon is already running for set $SETNAME!\n";
+ die "Slon is already running for the '$SETNAME' set\n";
}
my $dsn = $DSN[$nodenum];
my $dbname=$DBNAME[$nodenum];
start_slon($nodenum);
-
$pid = get_pid($node);
-if (!($pid)) {
+unless ($pid) {
print "Slon failed to start for cluster $SETNAME, node $node\n";
} else {
print "Slon successfully started for cluster $SETNAME, node $node\n";
print "PID [$pid]\n";
+ if ($START_WATCHDOG) {
print "Start the watchdog process as well...\n";
- system "perl slon_watchdog.pl $node $SLEEPTIME &";
+ system "perl slon_watchdog.pl $node $SLEEP_TIME &";
+ }
}
- Previous message: [Slony1-commit] By cbbrowne: Add in support for SSL connections Thanks to Steve Simms
- Next message: [Slony1-commit] By cbbrowne: Some fixes to spelling in comments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list