Start using the centralized pidfile and logfile name generation

subroutines for http and tftp test suite servers.
This commit is contained in:
Yang Tse
2010-01-08 15:54:07 +00:00
parent 184f92d243
commit aa2f447400
4 changed files with 241 additions and 61 deletions

View File

@@ -1,44 +1,114 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://curl.haxx.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# $Id$
#***************************************************************************
BEGIN {
@INC=(@INC, $ENV{'srcdir'}, '.');
}
use strict;
use warnings;
my $verbose=0; # set to 1 for debugging
use serverhelp qw(
server_pidfilename
server_logfilename
);
my $dir=".";
my $port = 8999; # just a default
my $ipv6;
my $pid=".http.pid"; # name of the pidfile
my $verbose = 0; # set to 1 for debugging
my $port = 8990; # just a default
my $ipvnum = 4; # default IP version of http server
my $idnum = 1; # dafault http server instance number
my $proto = 'http'; # protocol the http server speaks
my $pidfile; # http server pid file
my $logfile; # http server log file
my $srcdir;
my $fork;
my $flags = "";
my $path = '.';
my $logdir = $path .'/log';
do {
if($ARGV[0] eq "-v") {
$verbose=1;
while(@ARGV) {
if($ARGV[0] eq '--pidfile') {
if($ARGV[1]) {
$pidfile = $ARGV[1];
shift @ARGV;
}
}
elsif($ARGV[0] eq "-d") {
$dir=$ARGV[1];
shift @ARGV;
elsif($ARGV[0] eq '--logfile') {
if($ARGV[1]) {
$logfile = $ARGV[1];
shift @ARGV;
}
}
elsif($ARGV[0] eq "-p") {
$pid=$ARGV[1];
shift @ARGV;
elsif($ARGV[0] eq '--srcdir') {
if($ARGV[1]) {
$srcdir = $ARGV[1];
shift @ARGV;
}
}
elsif($ARGV[0] eq "--fork") {
elsif($ARGV[0] eq '--ipv4') {
$ipvnum = 4;
}
elsif($ARGV[0] eq '--ipv6') {
$ipvnum = 6;
}
elsif($ARGV[0] eq '--port') {
if($ARGV[1] =~ /^(\d+)$/) {
$port = $1;
shift @ARGV;
}
}
elsif($ARGV[0] eq '--id') {
if($ARGV[1] =~ /^(\d+)$/) {
$idnum = $1 if($1 > 0);
shift @ARGV;
}
}
elsif($ARGV[0] eq '--verbose') {
$verbose = 1;
}
elsif($ARGV[0] eq '--fork') {
$fork = $ARGV[0];
shift @ARGV;
}
elsif($ARGV[0] =~ /^(\d+)$/) {
$port = $1;
else {
print STDERR "\nWarning: httpserver.pl unknown parameter: $ARGV[0]\n";
}
elsif($ARGV[0] =~ /^ipv6/i) {
$ipv6="--ipv6 ";
}
} while(shift @ARGV);
shift @ARGV;
}
if(!$srcdir) {
$srcdir = $ENV{'srcdir'} || '.';
}
if(!$pidfile) {
$pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum);
}
if(!$logfile) {
$logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
}
$flags .= "--pidfile \"$pid\" ";
$flags .= "--fork " if(defined($fork));
$flags .= "--ipv6 " if(defined($ipv6));
$flags .= "--port $port --srcdir \"$dir\"";
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
exec("server/sws $flags");