From 96fc66487502ee9ac09c7233f7fefb0d7d9e0a52 Mon Sep 17 00:00:00 2001 From: "Yichun Zhang (agentzh)" Date: Wed, 20 Aug 2014 15:27:35 -0700 Subject: [PATCH] resty: added the -V option. --- util/resty | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/util/resty b/util/resty index 8cd494e..54a066b 100755 --- a/util/resty +++ b/util/resty @@ -15,13 +15,23 @@ use File::Temp qw( tempdir ); use POSIX qw( WNOHANG ); my %opts; -getopts("he:c:", \%opts) +getopts("he:c:V", \%opts) or usage(1); if ($opts{h}) { usage(0); } +my $nginx_path = File::Spec->catfile($FindBin::Bin, "..", "nginx", "sbin", "nginx"); +#warn $nginx_path; +if (!-f $nginx_path) { + $nginx_path = "nginx"; # find in PATH +} + +if ($opts{V}) { + exec "$nginx_path -V"; +} + my $luafile; if (!defined $opts{e}) { $luafile = shift @@ -34,12 +44,6 @@ if (@ARGV) { my $conns = $opts{c} || 64; -my $nginx_path = File::Spec->catfile($FindBin::Bin, "..", "nginx", "sbin", "nginx"); -#warn $nginx_path; -if (!-f $nginx_path) { - $nginx_path = "nginx"; # find in PATH -} - my $prefix_dir = tempdir(CLEANUP => 1); #warn "prefix dir: $prefix_dir\n"; @@ -196,12 +200,13 @@ if ($pid == 0) { # child process sub usage { my $rc = shift; my $msg = <<_EOC_; -$0 [-h] [-c num] [-e prog] [lua-file] +$0 [-h] [-c num] [-e prog] [-V] [lua-file] Options: -c num set maximal connection count (default: 64). -e prog run the inlined Lua code in "prog". -h print this help. + -V print the underlying nginx version and configurations. _EOC_ if ($rc == 0) { print $msg;