mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
support the new --id command line option, that allows a second (or third or
whatever) instance to run without overwriting the previous' logfiles
This commit is contained in:
parent
ae03fa7d8e
commit
3851c6aae2
@ -38,11 +38,13 @@ use strict;
|
|||||||
|
|
||||||
require "getpart.pm";
|
require "getpart.pm";
|
||||||
|
|
||||||
|
my $ftpdnum="";
|
||||||
|
|
||||||
# open and close each time to allow removal at any time
|
# open and close each time to allow removal at any time
|
||||||
sub logmsg {
|
sub logmsg {
|
||||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
|
||||||
localtime(time);
|
localtime(time);
|
||||||
open(FTPLOG, ">>log/ftpd.log");
|
open(FTPLOG, ">>log/ftpd$ftpdnum.log");
|
||||||
printf FTPLOG ("%02d:%02d:%02d ", $hour, $min, $sec);
|
printf FTPLOG ("%02d:%02d:%02d ", $hour, $min, $sec);
|
||||||
print FTPLOG @_;
|
print FTPLOG @_;
|
||||||
close(FTPLOG);
|
close(FTPLOG);
|
||||||
@ -50,8 +52,8 @@ sub logmsg {
|
|||||||
|
|
||||||
sub ftpmsg {
|
sub ftpmsg {
|
||||||
# append to the server.input file
|
# append to the server.input file
|
||||||
open(INPUT, ">>log/server.input") ||
|
open(INPUT, ">>log/server$ftpdnum.input") ||
|
||||||
logmsg "failed to open log/server.input\n";
|
logmsg "failed to open log/server$ftpdnum.input\n";
|
||||||
|
|
||||||
INPUT->autoflush(1);
|
INPUT->autoflush(1);
|
||||||
print INPUT @_;
|
print INPUT @_;
|
||||||
@ -77,6 +79,10 @@ do {
|
|||||||
$srcdir=$ARGV[1];
|
$srcdir=$ARGV[1];
|
||||||
shift @ARGV;
|
shift @ARGV;
|
||||||
}
|
}
|
||||||
|
elsif($ARGV[0] eq "--id") {
|
||||||
|
$ftpdnum=$ARGV[1];
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
elsif($ARGV[0] =~ /^(\d+)$/) {
|
elsif($ARGV[0] =~ /^(\d+)$/) {
|
||||||
$port = $1;
|
$port = $1;
|
||||||
}
|
}
|
||||||
@ -90,9 +96,10 @@ setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
|
|||||||
bind(Server, sockaddr_in($port, INADDR_ANY))|| die "bind: $!";
|
bind(Server, sockaddr_in($port, INADDR_ANY))|| die "bind: $!";
|
||||||
listen(Server,SOMAXCONN) || die "listen: $!";
|
listen(Server,SOMAXCONN) || die "listen: $!";
|
||||||
|
|
||||||
#print "FTP server started on port $port\n";
|
|
||||||
|
|
||||||
open(PID, ">.ftp.pid");
|
logmsg "FTP server started on port $port\n";
|
||||||
|
|
||||||
|
open(PID, ">.ftp$ftpdnum.pid");
|
||||||
print PID $$;
|
print PID $$;
|
||||||
close(PID);
|
close(PID);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user