123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- use Cwd;
- use Cwd 'abs_path';
- use File::Basename;
- my $logdir = "log";
- my $pidfile = "$logdir/nghttpx.pid";
- my $logfile = "$logdir/http2.log";
- my $nghttpx = "nghttpx";
- my $listenport = 9015;
- my $listenport2 = 9016;
- my $connect = "127.0.0.1,8990";
- my $conf = "nghttpx.conf";
- my $cert = "Server-localhost-sv";
- my $dev_null = ($^O eq 'MSWin32' ? 'NUL' : '/dev/null');
- while(@ARGV) {
- if($ARGV[0] eq '--verbose') {
- $verbose = 1;
- }
- elsif($ARGV[0] eq '--pidfile') {
- if($ARGV[1]) {
- $pidfile = $ARGV[1];
- shift @ARGV;
- }
- }
- elsif($ARGV[0] eq '--nghttpx') {
- if($ARGV[1]) {
- $nghttpx = $ARGV[1];
- shift @ARGV;
- }
- }
- elsif($ARGV[0] eq '--port') {
- if($ARGV[1]) {
- $listenport = $ARGV[1];
- shift @ARGV;
- }
- }
- elsif($ARGV[0] eq '--port2') {
- if($ARGV[1]) {
- $listenport2 = $ARGV[1];
- shift @ARGV;
- }
- }
- elsif($ARGV[0] eq '--connect') {
- if($ARGV[1]) {
- $connect = $ARGV[1];
- $connect =~ s/:/,/;
- shift @ARGV;
- }
- }
- elsif($ARGV[0] eq '--logfile') {
- if($ARGV[1]) {
- $logfile = $ARGV[1];
- shift @ARGV;
- }
- }
- elsif($ARGV[0] eq '--logdir') {
- if($ARGV[1]) {
- $logdir = $ARGV[1];
- shift @ARGV;
- }
- }
- elsif($ARGV[0] eq '--conf') {
- if($ARGV[1]) {
- $conf = $ARGV[1];
- shift @ARGV;
- }
- }
- else {
- print STDERR "\nWarning: http2-server.pl unknown parameter: $ARGV[0]\n";
- }
- shift @ARGV;
- }
- my $srcdir = dirname(__FILE__);
- $certfile = "$srcdir/certs/$cert.pem";
- $keyfile = "$srcdir/certs/$cert.key";
- $certfile = abs_path($certfile);
- $keyfile = abs_path($keyfile);
- my $cmdline="$nghttpx --backend=$connect ".
- "--backend-keep-alive-timeout=500ms ".
- "--frontend=\"*,$listenport;no-tls\" ".
- "--frontend=\"*,$listenport2\" ".
- "--log-level=INFO ".
- "--pid-file=$pidfile ".
- "--conf=$conf ".
- "--errorlog-file=$logfile ".
- "$keyfile $certfile";
- print "RUN: $cmdline\n" if($verbose);
- exec("exec $cmdline 2>$dev_null");
|