2013-04-17 02:19:26 +02:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Getopt::Std qw(getopts);
|
|
|
|
use Cwd qw/cwd/;
|
|
|
|
|
2018-11-02 05:23:39 +01:00
|
|
|
sub sh ($@);
|
2016-11-13 19:15:47 +01:00
|
|
|
sub cleanup ();
|
2015-03-01 06:14:50 +01:00
|
|
|
sub write_config_file ($);
|
2013-04-17 02:19:26 +02:00
|
|
|
|
2019-09-08 07:52:24 +02:00
|
|
|
BEGIN {
|
|
|
|
$ENV{LC_ALL} = 'C';
|
|
|
|
}
|
|
|
|
|
2013-04-17 02:19:26 +02:00
|
|
|
my %opts;
|
2014-05-17 23:19:01 +02:00
|
|
|
getopts("lf:", \%opts) or die "Usage: $0 [-f] [-l] <cores>\n";
|
2013-04-17 02:19:26 +02:00
|
|
|
|
|
|
|
my $jobs = shift || 4;
|
|
|
|
|
|
|
|
my $cwd = cwd();
|
2016-01-25 23:33:53 +01:00
|
|
|
if ($cwd !~ /openresty-(\d+(?:\.\d+)+(?:rc\d+(?:\.\d+)?)?)$/) {
|
2013-04-17 02:19:26 +02:00
|
|
|
die "Bad current working directory: $cwd\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
my $ver = $1;
|
|
|
|
|
2013-04-17 21:08:54 +02:00
|
|
|
my ($make, $lua);
|
2013-04-17 02:19:26 +02:00
|
|
|
|
|
|
|
if ($^O eq 'freebsd' || $^O eq 'solaris') {
|
|
|
|
$make = 'gmake';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$make = 'make';
|
|
|
|
}
|
|
|
|
|
2015-06-23 16:33:01 +02:00
|
|
|
my $cfg_opts = "";
|
2013-04-17 21:08:54 +02:00
|
|
|
|
2017-04-09 02:33:54 +02:00
|
|
|
$lua = 'LuaJIT';
|
|
|
|
#$cfg_opts .= " --with-luajit";
|
2013-04-17 21:08:54 +02:00
|
|
|
|
2013-11-13 05:43:55 +01:00
|
|
|
if ($^O eq 'solaris') {
|
|
|
|
$cfg_opts .= " --with-cc=gcc";
|
|
|
|
}
|
|
|
|
|
2015-03-01 06:14:50 +01:00
|
|
|
if ($^O eq 'darwin') {
|
2016-01-22 03:59:59 +01:00
|
|
|
$cfg_opts .= " --with-cc-opt='-I/usr/local/opt/openssl/include/ "
|
|
|
|
. "-I/usr/local/opt/pcre/include/'"
|
|
|
|
. " --with-ld-opt='-L/usr/local/opt/openssl/lib/ "
|
|
|
|
. "-L/usr/local/opt/pcre/lib/'";
|
2018-04-20 00:04:24 +02:00
|
|
|
|
|
|
|
} else {
|
|
|
|
my $ssl_prefix = $ENV{OPENSSL_PREFIX};
|
|
|
|
if (defined $ssl_prefix) {
|
|
|
|
$cfg_opts .= " --with-cc-opt='-I$ssl_prefix/include/' "
|
|
|
|
. " --with-ld-opt='-L$ssl_prefix/lib/' ";
|
|
|
|
}
|
2015-03-01 06:14:50 +01:00
|
|
|
}
|
|
|
|
|
2013-04-17 02:19:26 +02:00
|
|
|
my $prefix;
|
|
|
|
|
2015-03-01 06:14:50 +01:00
|
|
|
my $config = do { local $/; <DATA> };
|
|
|
|
|
|
|
|
sub write_config_file ($) {
|
|
|
|
my $outfile = shift;
|
|
|
|
warn "Writing file $outfile\n";
|
|
|
|
open my $out, ">$outfile" or
|
|
|
|
die "Cannot open $outfile for writing: $!\n";
|
|
|
|
print $out $config;
|
|
|
|
close $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
write_config_file "/tmp/nginx.conf";
|
|
|
|
|
2018-11-02 01:42:24 +01:00
|
|
|
if (1) {
|
|
|
|
|
|
|
|
warn "\n=== --without-stream ===\n";
|
|
|
|
$prefix = "/usr/local/openresty-nostream";
|
2016-11-13 19:15:47 +01:00
|
|
|
cleanup();
|
2016-01-11 23:04:53 +01:00
|
|
|
unless ($opts{f}) {
|
2018-11-02 01:42:24 +01:00
|
|
|
sh "./configure $cfg_opts --without-stream --prefix=$prefix -j$jobs";
|
2016-01-11 23:04:53 +01:00
|
|
|
}
|
2018-11-02 01:42:24 +01:00
|
|
|
sh "$make -j$jobs";
|
|
|
|
sh "sudo $make install";
|
2016-01-11 23:04:53 +01:00
|
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
2018-11-02 01:42:24 +01:00
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep -v 'stream_proxy'";
|
2023-07-17 10:49:36 +02:00
|
|
|
#system "[ -f '$prefix/nginx/logs/nginx.pid' ] && sudo kill \$(cat '$prefix/nginx/logs/nginx.pid') > /dev/null 2>&1";
|
2016-01-11 23:04:53 +01:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
|
|
|
sh "curl -si localhost/lua|grep $lua";
|
|
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
2020-10-02 08:09:34 +02:00
|
|
|
sh qq{$prefix/bin/resty --no-stream -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
2016-01-11 23:04:53 +01:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
|
2018-11-02 05:23:39 +01:00
|
|
|
}
|
|
|
|
|
2020-01-03 05:35:40 +01:00
|
|
|
#warn "\n=== --without-stream + dtrace static probes ===\n";
|
|
|
|
#$prefix = "/usr/local/openresty-nostream-usdt";
|
|
|
|
#cleanup();
|
|
|
|
#unless ($opts{f}) {
|
|
|
|
#sh "./configure $cfg_opts --with-dtrace-probes --without-stream --prefix=$prefix -j$jobs";
|
|
|
|
#}
|
|
|
|
#sh "$make -j$jobs";
|
|
|
|
#sh "sudo $make install";
|
|
|
|
#sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
|
|
|
#sh "$prefix/nginx/sbin/nginx -V 2>\&1", $ver;
|
|
|
|
#sh "$prefix/nginx/sbin/nginx -V 2>\&1", "--with-stream", 1;
|
|
|
|
#sh "$prefix/nginx/sbin/nginx -V 2>\&1", "--with-dtrace-probes";
|
2023-07-17 10:49:36 +02:00
|
|
|
#system "[ -f '$prefix/nginx/logs/nginx.pid' ] && sudo kill \$(cat '$prefix/nginx/logs/nginx.pid') > /dev/null 2>&1";
|
2020-01-03 05:35:40 +01:00
|
|
|
#sh "sudo $prefix/nginx/sbin/nginx";
|
|
|
|
#sh "curl -si localhost/lua|grep $lua";
|
|
|
|
#sh "curl -si localhost/lua|grep $ver";
|
|
|
|
#sh "curl -si localhost/cjson|grep 'json.safe: '";
|
|
|
|
#sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'}, 'Hello World';
|
|
|
|
#sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
2016-01-11 23:04:53 +01:00
|
|
|
|
2017-03-20 05:15:31 +01:00
|
|
|
warn "\n=== Without Gzip/SSL/PCRE ===\n";
|
2015-01-29 23:56:02 +01:00
|
|
|
$prefix = "/usr/local/openresty-nogzip";
|
2016-11-13 19:15:47 +01:00
|
|
|
cleanup();
|
2015-01-29 23:56:02 +01:00
|
|
|
unless ($opts{f}) {
|
2018-11-02 01:42:24 +01:00
|
|
|
sh "./configure $cfg_opts --without-http_rewrite_module --without-http_ssl_module --without-pcre --without-http_gzip_module --prefix=$prefix -j$jobs";
|
2015-01-29 23:56:02 +01:00
|
|
|
}
|
2018-11-02 01:42:24 +01:00
|
|
|
sh "$make -j$jobs";
|
|
|
|
sh "sudo $make install";
|
2015-03-01 06:14:50 +01:00
|
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
2015-01-29 23:56:02 +01:00
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--without-http_gzip_module'";
|
2015-06-23 16:33:01 +02:00
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep -v -q '\\--with-http_ssl_module'";
|
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--without-pcre'";
|
2023-07-17 10:49:36 +02:00
|
|
|
system "[ -f '$prefix/nginx/logs/nginx.pid' ] && sudo kill \$(cat '$prefix/nginx/logs/nginx.pid') > /dev/null 2>&1";
|
2018-11-02 01:42:24 +01:00
|
|
|
if (0) {
|
2015-01-29 23:56:02 +01:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
|
|
|
sh "curl -si localhost/lua|grep $lua";
|
|
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
2017-06-27 07:14:20 +02:00
|
|
|
#sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
2015-01-29 23:56:02 +01:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
2018-11-02 01:42:24 +01:00
|
|
|
}
|
2015-01-29 23:56:02 +01:00
|
|
|
|
2015-06-23 16:33:01 +02:00
|
|
|
$cfg_opts .= " --with-http_iconv_module";
|
|
|
|
|
2015-07-03 17:23:41 +02:00
|
|
|
warn "\n=== --with-threads ===\n";
|
|
|
|
$prefix = "/usr/local/openresty-threads";
|
2016-11-13 19:15:47 +01:00
|
|
|
cleanup();
|
2015-07-03 17:23:41 +02:00
|
|
|
unless ($opts{f}) {
|
2018-11-02 01:42:24 +01:00
|
|
|
sh "./configure $cfg_opts --with-threads --prefix=$prefix -j$jobs";
|
2015-07-03 17:23:41 +02:00
|
|
|
}
|
2018-11-02 01:42:24 +01:00
|
|
|
sh "$make -j$jobs";
|
|
|
|
sh "sudo $make install";
|
2015-07-03 17:23:41 +02:00
|
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-threads'";
|
2023-07-17 10:49:36 +02:00
|
|
|
system "[ -f '$prefix/nginx/logs/nginx.pid' ] && sudo kill \$(cat '$prefix/nginx/logs/nginx.pid') > /dev/null 2>&1";
|
2015-07-03 17:23:41 +02:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
|
|
|
sh "curl -si localhost/lua|grep $lua";
|
|
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
|
|
|
sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
|
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
|
2015-01-29 23:56:02 +01:00
|
|
|
warn "\n=== No Pool Build ===\n";
|
2013-06-12 01:51:26 +02:00
|
|
|
$prefix = "/usr/local/openresty-nopool";
|
2016-11-13 19:15:47 +01:00
|
|
|
cleanup();
|
2013-06-12 01:51:26 +02:00
|
|
|
unless ($opts{f}) {
|
|
|
|
sh "./configure --with-no-pool-patch $cfg_opts --prefix=$prefix -j$jobs > /dev/null";
|
|
|
|
}
|
|
|
|
sh "$make -j$jobs > /dev/null";
|
|
|
|
sh "sudo $make install > /dev/null";
|
2015-03-01 06:14:50 +01:00
|
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
2013-06-12 01:51:26 +02:00
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
|
|
#sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-no-pool-patch'";
|
2023-07-17 10:49:36 +02:00
|
|
|
system "[ -f '$prefix/nginx/logs/nginx.pid' ] && sudo kill \$(cat '$prefix/nginx/logs/nginx.pid') > /dev/null 2>&1";
|
2013-06-12 01:51:26 +02:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
|
|
|
sh "curl -si localhost/lua|grep $lua";
|
|
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
|
|
sh "curl -si localhost/lua|grep 'no pool'";
|
2014-03-01 06:22:33 +01:00
|
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
2015-01-21 23:53:26 +01:00
|
|
|
sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
2013-06-12 01:51:26 +02:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
|
|
|
|
warn "\n=== Normal Build ===\n";
|
2013-04-17 02:19:26 +02:00
|
|
|
$prefix = "/usr/local/openresty";
|
2016-11-13 19:15:47 +01:00
|
|
|
cleanup();
|
2013-04-17 02:19:26 +02:00
|
|
|
unless ($opts{f}) {
|
2018-11-02 01:42:24 +01:00
|
|
|
sh "./configure $cfg_opts -j$jobs";
|
2013-04-17 02:19:26 +02:00
|
|
|
}
|
2018-11-02 01:42:24 +01:00
|
|
|
sh "$make -j$jobs";
|
|
|
|
sh "sudo $make install";
|
2015-03-01 06:14:50 +01:00
|
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
2023-07-17 10:49:36 +02:00
|
|
|
system "[ -f '$prefix/nginx/logs/nginx.pid' ] && sudo kill \$(cat '$prefix/nginx/logs/nginx.pid') > /dev/null 2>&1";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
2013-04-17 21:08:54 +02:00
|
|
|
sh "curl -si localhost/lua|grep $lua";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "curl -si localhost/lua|grep $ver";
|
2014-03-01 06:22:33 +01:00
|
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
2015-01-21 23:53:26 +01:00
|
|
|
sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
2016-11-13 19:15:47 +01:00
|
|
|
sh qq{$prefix/bin/restydoc -s listen | grep 'configures the port to accept HTTP/2'};
|
|
|
|
sh qq{$prefix/bin/restydoc opm | grep -E '^Status\$'};
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
|
|
|
|
warn "\n=== Debug Build ===\n";
|
|
|
|
$prefix = "/usr/local/openresty-debug";
|
2016-11-13 19:15:47 +01:00
|
|
|
cleanup();
|
2013-04-17 02:19:26 +02:00
|
|
|
unless ($opts{f}) {
|
2014-05-17 23:19:01 +02:00
|
|
|
my $more_cfg_opts = '';
|
|
|
|
if ($lua eq 'LuaJIT') {
|
|
|
|
$more_cfg_opts .= " --with-luajit-xcflags='-DLUA_USE_TRACE_LOGS'"
|
|
|
|
}
|
2018-11-02 01:42:24 +01:00
|
|
|
sh "./configure --with-debug $cfg_opts $more_cfg_opts --prefix=$prefix -j$jobs";
|
2013-04-17 02:19:26 +02:00
|
|
|
}
|
2018-11-02 01:42:24 +01:00
|
|
|
sh "$make -j$jobs";
|
|
|
|
sh "sudo $make install";
|
2015-03-01 06:14:50 +01:00
|
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-debug'";
|
2023-07-17 10:49:36 +02:00
|
|
|
system "[ -f '$prefix/nginx/logs/nginx.pid' ] && sudo kill \$(cat '$prefix/nginx/logs/nginx.pid') > /dev/null 2>&1";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
2013-04-17 21:08:54 +02:00
|
|
|
sh "curl -si localhost/lua|grep $lua";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "curl -si localhost/lua|grep $ver";
|
2014-03-01 06:22:33 +01:00
|
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
2015-01-21 23:53:26 +01:00
|
|
|
sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
|
2020-01-03 05:35:40 +01:00
|
|
|
#warn "\n=== DTrace Build ===\n";
|
|
|
|
#$prefix = "/usr/local/openresty-dtrace";
|
|
|
|
#cleanup();
|
|
|
|
#unless ($opts{f}) {
|
|
|
|
#sh "./configure $cfg_opts --with-dtrace-probes --prefix=$prefix -j$jobs";
|
|
|
|
#}
|
|
|
|
#sh "$make -j$jobs";
|
|
|
|
#sh "sudo $make install";
|
|
|
|
#sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
|
|
|
#sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
|
|
#sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-dtrace-probes'";
|
2023-07-17 10:49:36 +02:00
|
|
|
#system "[ -f '$prefix/nginx/logs/nginx.pid' ] && sudo kill \$(cat '$prefix/nginx/logs/nginx.pid') > /dev/null 2>&1";
|
2020-01-03 05:35:40 +01:00
|
|
|
#sh "sudo $prefix/nginx/sbin/nginx";
|
|
|
|
#sh "curl -si localhost/lua|grep $lua";
|
|
|
|
#sh "curl -si localhost/lua|grep $ver";
|
|
|
|
#sh "curl -si localhost/cjson|grep 'json.safe: '";
|
|
|
|
#if ($^O eq 'linux') {
|
|
|
|
#sh "stap -L 'process(\"$prefix/nginx/sbin/nginx\").mark(\"*\")'|grep http__lua__coroutine__done";
|
|
|
|
#
|
|
|
|
#} elsif ($^O eq 'freebsd' || $^O eq 'darwin' || $^O eq 'solaris') {
|
|
|
|
#sh "sudo dtrace -l|grep http-lua-coroutine-done";
|
|
|
|
#}
|
|
|
|
#sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
2013-04-17 02:19:26 +02:00
|
|
|
|
2020-01-03 05:35:40 +01:00
|
|
|
#sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
2013-04-17 02:19:26 +02:00
|
|
|
|
2018-11-02 01:42:24 +01:00
|
|
|
sub sh ($@) {
|
2013-04-17 02:19:26 +02:00
|
|
|
my $cmd = shift;
|
2018-11-02 01:42:24 +01:00
|
|
|
my $pat = shift;
|
2018-11-02 05:23:39 +01:00
|
|
|
my $neg = shift;
|
2018-11-02 01:42:24 +01:00
|
|
|
open my $in, "$cmd|"
|
|
|
|
or die "Command \"$cmd\" failed";
|
|
|
|
my $out = '';
|
|
|
|
my $found;
|
|
|
|
while (<$in>) {
|
2018-11-02 05:23:39 +01:00
|
|
|
if (defined $pat) {
|
|
|
|
if ($neg && index($_, $pat) < 0) {
|
|
|
|
$found = 1;
|
|
|
|
} elsif (!$neg && index($_, $pat) >= 0) {
|
|
|
|
$found = 1;
|
|
|
|
}
|
2018-11-02 01:42:24 +01:00
|
|
|
}
|
|
|
|
$out .= $_;
|
|
|
|
}
|
|
|
|
close $in
|
|
|
|
or die "Failed to run command \"$cmd\": $out";
|
|
|
|
if (!defined $found && defined $pat) {
|
2018-11-02 05:23:39 +01:00
|
|
|
if ($neg) {
|
|
|
|
die "unexpectedly found pattern '$pat' in the output of command \"$cmd\": $out";
|
|
|
|
}
|
2018-11-02 01:42:24 +01:00
|
|
|
die "failed find pattern '$pat' in the output of command \"$cmd\": $out";
|
|
|
|
}
|
|
|
|
if (length $out < 1024) {
|
|
|
|
print $out;
|
|
|
|
}
|
2013-04-17 02:19:26 +02:00
|
|
|
}
|
2015-03-01 06:14:50 +01:00
|
|
|
|
2016-11-13 19:15:47 +01:00
|
|
|
sub cleanup () {
|
2019-08-07 02:20:42 +02:00
|
|
|
sh "sudo rm -rf $prefix/lualib $prefix/luajit $prefix/bin $prefix/nginx/sbin $prefix/nginx/html"
|
2016-11-13 19:15:47 +01:00
|
|
|
. " $prefix/site $prefix/pod $prefix/resty.index";
|
|
|
|
}
|
|
|
|
|
2015-03-01 06:14:50 +01:00
|
|
|
__DATA__
|
|
|
|
|
|
|
|
user nobody;
|
2017-06-27 07:14:20 +02:00
|
|
|
worker_processes 2;
|
2015-03-01 06:14:50 +01:00
|
|
|
error_log logs/error.log;
|
|
|
|
pid logs/nginx.pid;
|
|
|
|
|
|
|
|
events {
|
|
|
|
accept_mutex off;
|
|
|
|
worker_connections 256;
|
|
|
|
}
|
|
|
|
|
|
|
|
http {
|
|
|
|
include mime.types;
|
|
|
|
default_type application/octet-stream;
|
|
|
|
|
2017-06-27 07:14:20 +02:00
|
|
|
init_by_lua_block {
|
2015-03-01 06:14:50 +01:00
|
|
|
if jit then
|
|
|
|
require "resty.core"
|
|
|
|
end
|
2017-06-27 07:14:20 +02:00
|
|
|
}
|
2015-03-01 06:14:50 +01:00
|
|
|
|
2016-01-11 23:04:53 +01:00
|
|
|
upstream backend {
|
|
|
|
server 0.0.0.1;
|
|
|
|
balancer_by_lua_block {
|
|
|
|
print("balancer!")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-01 06:14:50 +01:00
|
|
|
server {
|
|
|
|
listen *:80;
|
|
|
|
server_name localhost;
|
|
|
|
|
|
|
|
location = /lua {
|
2017-06-27 07:14:20 +02:00
|
|
|
content_by_lua_block {
|
2015-03-01 06:14:50 +01:00
|
|
|
local upstream = require "ngx.upstream"
|
|
|
|
if jit then
|
|
|
|
ngx.say(jit.version)
|
|
|
|
else
|
|
|
|
ngx.say(_VERSION)
|
|
|
|
end
|
2017-06-27 07:14:20 +02:00
|
|
|
}
|
2015-03-01 06:14:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
location = /cjson {
|
2017-06-27 07:14:20 +02:00
|
|
|
content_by_lua_block {
|
2015-03-01 06:14:50 +01:00
|
|
|
local json = require "cjson.safe"
|
|
|
|
ngx.say("cjson.safe: ", json.encode{foo = 123})
|
2017-06-27 07:14:20 +02:00
|
|
|
}
|
2015-03-01 06:14:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|