mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
make sure the ipv6 http server gets its pid stored in a separate file
This commit is contained in:
parent
1faef62d59
commit
dc28a9c0c1
@ -7,6 +7,7 @@ my $verbose=0; # set to 1 for debugging
|
|||||||
my $dir=".";
|
my $dir=".";
|
||||||
my $port = 8999; # just a default
|
my $port = 8999; # just a default
|
||||||
my $ipv6;
|
my $ipv6;
|
||||||
|
my $pid=".http.pid"; # name of the pidfile
|
||||||
do {
|
do {
|
||||||
if($ARGV[0] eq "-v") {
|
if($ARGV[0] eq "-v") {
|
||||||
$verbose=1;
|
$verbose=1;
|
||||||
@ -15,6 +16,10 @@ do {
|
|||||||
$dir=$ARGV[1];
|
$dir=$ARGV[1];
|
||||||
shift @ARGV;
|
shift @ARGV;
|
||||||
}
|
}
|
||||||
|
elsif($ARGV[0] eq "-p") {
|
||||||
|
$pid=$ARGV[1];
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
elsif($ARGV[0] =~ /^(\d+)$/) {
|
elsif($ARGV[0] =~ /^(\d+)$/) {
|
||||||
$port = $1;
|
$port = $1;
|
||||||
}
|
}
|
||||||
@ -23,4 +28,4 @@ do {
|
|||||||
}
|
}
|
||||||
} while(shift @ARGV);
|
} while(shift @ARGV);
|
||||||
|
|
||||||
exec("server/sws $ipv6$port $dir");
|
exec("server/sws --pidfile $pid $ipv6$port $dir");
|
||||||
|
@ -346,7 +346,6 @@ sub runhttpserver {
|
|||||||
$nameext="-ipv6";
|
$nameext="-ipv6";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$pid = checkserver($pidfile);
|
$pid = checkserver($pidfile);
|
||||||
|
|
||||||
# verify if our/any server is running on this port
|
# verify if our/any server is running on this port
|
||||||
@ -391,7 +390,7 @@ sub runhttpserver {
|
|||||||
if($dir) {
|
if($dir) {
|
||||||
$flag .= "-d \"$dir\" ";
|
$flag .= "-d \"$dir\" ";
|
||||||
}
|
}
|
||||||
$cmd="$perl $srcdir/httpserver.pl $flag $port $ipv6 &";
|
$cmd="$perl $srcdir/httpserver.pl -p $pidfile $flag $port $ipv6 &";
|
||||||
system($cmd);
|
system($cmd);
|
||||||
if($verbose) {
|
if($verbose) {
|
||||||
print "CMD: $cmd\n";
|
print "CMD: $cmd\n";
|
||||||
|
@ -728,11 +728,12 @@ int main(int argc, char *argv[])
|
|||||||
int sock, msgsock, flag;
|
int sock, msgsock, flag;
|
||||||
unsigned short port = DEFAULT_PORT;
|
unsigned short port = DEFAULT_PORT;
|
||||||
FILE *pidfile;
|
FILE *pidfile;
|
||||||
|
char *pidname= (char *)".http.pid";
|
||||||
struct httprequest req;
|
struct httprequest req;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if(argc>1) {
|
|
||||||
int arg=1;
|
int arg=1;
|
||||||
|
|
||||||
|
while(argc>arg) {
|
||||||
if(!strcmp("--version", argv[arg])) {
|
if(!strcmp("--version", argv[arg])) {
|
||||||
printf("sws IPv4%s\n",
|
printf("sws IPv4%s\n",
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
@ -743,20 +744,24 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(!strcmp("--ipv6", argv[arg])) {
|
else if(!strcmp("--pidfile", argv[arg])) {
|
||||||
|
arg++;
|
||||||
|
if(argc>arg)
|
||||||
|
pidname = argv[arg++];
|
||||||
|
}
|
||||||
|
else if(!strcmp("--ipv6", argv[arg])) {
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
use_ipv6=TRUE;
|
use_ipv6=TRUE;
|
||||||
#endif
|
#endif
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
if(argc>arg) {
|
else if(argc>arg) {
|
||||||
|
|
||||||
if(atoi(argv[arg]))
|
if(atoi(argv[arg]))
|
||||||
port = (unsigned short)atoi(argv[arg++]);
|
port = (unsigned short)atoi(argv[arg++]);
|
||||||
|
|
||||||
if(argc>arg)
|
if(argc>arg)
|
||||||
path = argv[arg];
|
path = argv[arg++];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -820,7 +825,7 @@ int main(int argc, char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pidfile = fopen(".http.pid", "w");
|
pidfile = fopen(pidname, "w");
|
||||||
if(pidfile) {
|
if(pidfile) {
|
||||||
fprintf(pidfile, "%d\n", (int)getpid());
|
fprintf(pidfile, "%d\n", (int)getpid());
|
||||||
fclose(pidfile);
|
fclose(pidfile);
|
||||||
|
Loading…
Reference in New Issue
Block a user