text
stringlengths
0
834k
close $out;
my @cmd = ($nginx_path, '-p', ""$prefix_dir/"", '-c', ""conf/nginx.conf"");
if ($use_gdb) {
if ($use_valgrind) {
die ""ERROR: options --gdb and --valgrind cannot be specified at the "",
""same time.\n"";
}
if ($use_rr) {
die ""ERROR: options --gdb and --rr cannot be specified at the "",
""same time.\n"";
}
if ($use_stap) {
die ""ERROR: options --gdb and --stap cannot be specified at the "",
""same time.\n"";
}
#warn ""use gdb opts: $gdb_opts"";
unshift @cmd, ""gdb"", defined $gdb_opts ? (split_sh_args $gdb_opts) : (),
""--args"",
} elsif ($use_rr) {
if ($use_valgrind) {
die ""ERROR: options --rr and --valgrind cannot be specified at the "",
""same time.\n"";
}
if ($use_stap) {
die ""ERROR: options --rr and --stap cannot be specified at the "",
""same time.\n"";
}
unshift @cmd, ""rr"", ""record"",
} elsif ($use_stap) {
if ($use_valgrind) {
die ""ERROR: options --stap and --valgrind cannot be specified at the "",
""same time.\n"";
}
@cmd = (""stap"", defined $stap_opts ? (split_sh_args $stap_opts) : (),
'-c', join_sh_args \@cmd);
} elsif ($use_valgrind) {
my @new = ('valgrind');
if (defined $valgrind_opts) {
push @new, split_sh_args $valgrind_opts;
}
unshift @cmd, @new;
} elsif (defined $user_runner) {
unshift @cmd, split_sh_args $user_runner;
#warn ""cmd: @cmd"";
}
for my $sig (qw/ INT TERM QUIT HUP USR1 USR2 WINCH PIPE /) {
$SIG{$sig} = \&forward_signal;
}
my $pid = fork();
if (!defined $pid) {
die ""fork() failed: $!\n"";
}
if ($pid == 0) { # child process
#use Data::Dumper;
#warn ""exec "", Dumper \@cmd;
#warn ""exec [@cmd]..."";
exec(@cmd)
or die ""ERROR: failed to run command \""@cmd\"": $!\n"";
} else {
$child_pid = $pid;
waitpid($child_pid, 0);
my $rc = 0;
if ($?) {
$rc = ($? >> 8);
if ($rc == 0) {
$rc = $?;
}
}
exit $rc;
}
sub usage {
my $rc = shift;
my $msg = <<_EOC_;
resty [options] [lua-file [args]]
Options:
-c NUM Set maximal connection count (default: 64).
-e PROG Run the inlined Lua code in ""prog"".
--errlog-level LEVEL