Compare commits

...

14 Commits

Author SHA1 Message Date
3ae5c4d93e updated the test suite to reflect recent changes. 2015-02-09 11:39:57 -08:00
e82793361b bumped version to 1.7.7.2 RC2. 2015-01-29 14:56:19 -08:00
55909727dd dist-check: added simple tests for builds without ngx_gzip module. 2015-01-29 14:56:02 -08:00
6b052c8fca bugfix: ngx_http_redis failed to compile when the ngx_gzip module was disabled. thanks anod221 for the report in #79. 2015-01-29 14:53:48 -08:00
fab852190b fixed the context line numbers in ngx_http_redis-0.3.7-variables_in_redis_pass.patch. 2015-01-29 12:49:20 -08:00
dc007ebcb9 upgraded LuaJIT to v2.1-20150120. 2015-01-21 14:58:00 -08:00
f46cfc667d bumped version to 1.7.7.2rc1. 2015-01-21 14:53:39 -08:00
5f6a50cacc util/dist-check: added simple checks for the "resty" utility. 2015-01-21 14:53:26 -08:00
16d0b04e1c upgraded lua-resty-core to 0.1.0. 2015-01-21 14:47:59 -08:00
076f2bd45e upgraded lua-resty-lrucache to 0.04. 2015-01-21 14:43:00 -08:00
b1a852b27e upgraded lua-resty-websocket to 0.05. 2015-01-21 14:33:30 -08:00
fdcdc15436 upgraded ngx_set_misc to 0.28. 2015-01-21 14:28:58 -08:00
916245656b upgraded ngx_lua to 0.9.14. 2015-01-21 14:21:00 -08:00
03b25469c8 feature: we bundle the resty-cli project to include its "resty" tool instead of using our own. 2014-12-29 14:49:08 -08:00
8 changed files with 718 additions and 980 deletions

View File

@ -1,5 +1,5 @@
--- ngx_http_redis-0.3.7/ngx_http_redis_module.c 2013-03-21 17:51:09.224660165 -0700
+++ ngx_http_redis-0.3.7-patched/ngx_http_redis_module.c 2013-03-21 17:50:51.928599875 -0700
--- ngx_http_redis-0.3.7/ngx_http_redis_module.c 2013-11-28 20:41:16.000000000 -0800
+++ ngx_http_redis-0.3.7-patched2/ngx_http_redis_module.c 2015-01-29 12:35:38.610133438 -0800
@@ -18,6 +18,8 @@ typedef struct {
ngx_int_t index;
ngx_int_t db;
@ -76,7 +76,7 @@
u->output.tag = (ngx_buf_tag_t) &ngx_http_redis_module;
#endif
@@ -835,24 +870,15 @@ ngx_http_redis_pass(ngx_conf_t *cf, ngx_
@@ -845,24 +880,15 @@ ngx_http_redis_pass(ngx_conf_t *cf, ngx_
ngx_str_t *value;
ngx_url_t u;
@ -104,7 +104,7 @@
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
clcf->handler = ngx_http_redis_handler;
@@ -869,6 +895,41 @@ ngx_http_redis_pass(ngx_conf_t *cf, ngx_
@@ -879,6 +905,41 @@ ngx_http_redis_pass(ngx_conf_t *cf, ngx_
rlcf->db = ngx_http_get_variable_index(cf, &ngx_http_redis_db);
@ -146,7 +146,7 @@
return NGX_CONF_OK;
}
@@ -906,3 +967,41 @@ ngx_http_redis_add_variables(ngx_conf_t
@@ -916,3 +977,41 @@ ngx_http_redis_add_variables(ngx_conf_t
return NGX_OK;
}

View File

@ -0,0 +1,12 @@
--- ngx_http_redis-0.3.7/ngx_http_redis_module.c 2013-11-28 20:41:16.000000000 -0800
+++ ngx_http_redis-0.3.7-patched/ngx_http_redis_module.c 2015-01-29 12:26:58.195973401 -0800
@@ -527,7 +527,9 @@ found:
ngx_str_set(&h->key, "Content-Encoding");
ngx_str_set(&h->value, "gzip");
h->lowcase_key = (u_char*) "content-encoding";
+#if (NGX_HTTP_GZIP)
u->headers_in.content_encoding = h;
+#endif
}
/* try to find end of string */

1312
t/sanity.t

File diff suppressed because it is too large Load Diff

8
util/configure vendored
View File

@ -312,8 +312,6 @@ push @make_cmds, "cd $root_dir/build/$ngx_dir && "
push @make_install_cmds, "cd $root_dir/build/$ngx_dir && "
. "\$(MAKE) install DESTDIR=\$(DESTDIR)";
push @make_install_cmds, "cd $root_dir/build && ./install resty \$(DESTDIR)/$prefix/bin/";
cd '../..'; # to the root
#die "pwd: " .. `pwd`;
@ -844,6 +842,12 @@ _EOC_
}
}
# configure resty-cli:
my $resty_cli_dir = auto_complete 'resty-cli';
push @make_install_cmds, "cd $root_dir/build/$resty_cli_dir && "
. "$root_dir/build/install resty \$(DESTDIR)/$prefix/bin/";
# prepare nginx configure line
$ngx_dir = auto_complete "nginx";

View File

@ -46,7 +46,24 @@ if ($^O eq 'solaris') {
my $prefix;
warn "=== No Pool Build ===\n";
warn "=== Without Gzip ===\n";
$prefix = "/usr/local/openresty-nogzip";
unless ($opts{f}) {
sh "./configure $cfg_opts --without-http_gzip_module --prefix=$prefix -j$jobs > /dev/null";
}
sh "$make -j$jobs > /dev/null";
sh "sudo $make install > /dev/null";
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--without-http_gzip_module'";
system "sudo killall nginx > /dev/null 2>&1";
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";
warn "\n=== No Pool Build ===\n";
$prefix = "/usr/local/openresty-nopool";
unless ($opts{f}) {
sh "./configure --with-no-pool-patch $cfg_opts --prefix=$prefix -j$jobs > /dev/null";
@ -61,6 +78,7 @@ sh "curl -si localhost/lua|grep $lua";
sh "curl -si localhost/lua|grep $ver";
sh "curl -si localhost/lua|grep 'no pool'";
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";
warn "\n=== Normal Build ===\n";
@ -76,6 +94,7 @@ 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";
warn "\n=== Debug Build ===\n";
@ -96,6 +115,7 @@ 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";
warn "\n=== DTrace Build ===\n";
@ -118,6 +138,7 @@ if ($^O eq 'linux') {
} 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'};
sh "sudo $prefix/nginx/sbin/nginx -sstop";

View File

@ -311,7 +311,7 @@ mv simpl-ngx_devel_kit-* ngx_devel_kit-$ver || exit 1
#################################
ver=0.27
ver=0.28
$root/util/get-tarball "https://github.com/openresty/set-misc-nginx-module/tarball/v$ver" -O set-misc-nginx-module-$ver.tar.gz || exit 1
tar -xzf set-misc-nginx-module-$ver.tar.gz || exit 1
mv openresty-set-misc-nginx-module-* set-misc-nginx-module-$ver || exit 1
@ -346,7 +346,7 @@ mv openresty-drizzle-nginx-module-* drizzle-nginx-module-$ver || exit 1
#################################
ver=0.9.13
ver=0.9.14
$root/util/get-tarball "https://github.com/openresty/lua-nginx-module/tarball/v$ver" -O lua-nginx-module-$ver.tar.gz || exit 1
tar -xzf lua-nginx-module-$ver.tar.gz || exit 1
mv openresty-lua-nginx-module-* ngx_lua-$ver || exit 1
@ -418,6 +418,9 @@ mv ngx_http_redis-* redis-nginx-module-$ver || exit 1
cd redis-nginx-module-$ver
echo "applying ngx_http_redis-$ver-variables_in_redis_pass.patch"
patch -p1 < $root/patches/ngx_http_redis-$ver-variables_in_redis_pass.patch || exit 1
echo "applying ngx_http_redis-$ver-without_gzip.patch"
patch -p1 < $root/patches/ngx_http_redis-$ver-without_gzip.patch || exit 1
cd ..
#################################
@ -443,6 +446,13 @@ mv openresty-redis2-nginx-module-* redis2-nginx-module-$ver || exit 1
#################################
ver=0.01
$root/util/get-tarball "https://github.com/openresty/resty-cli/tarball/v$ver" -O resty-cli-$ver.tar.gz || exit 1
tar -xzf resty-cli-$ver.tar.gz || exit 1
mv openresty-resty-cli-* resty-cli-$ver || exit 1
#################################
ver=5.1.5
$root/util/get-tarball "http://www.lua.org/ftp/lua-$ver.tar.gz" -O "lua-$ver.tar.gz" || exit 1
tar -xzf lua-$ver.tar.gz || exit 1
@ -469,7 +479,7 @@ echo
#################################
ver=2.1-20141128
ver=2.1-20150120
$root/util/get-tarball "https://github.com/openresty/luajit2/archive/v$ver.tar.gz" -O "LuaJIT-$ver.tar.gz" || exit 1
tar -xzf LuaJIT-$ver.tar.gz || exit 1
mv luajit2-* LuaJIT-$ver || exit 1
@ -555,7 +565,7 @@ mv openresty-lua-resty-string-* lua-resty-string-$ver || exit 1
#################################
ver=0.04
ver=0.05
$root/util/get-tarball "https://github.com/openresty/lua-resty-websocket/tarball/v$ver" -O "lua-resty-websocket-$ver.tar.gz" || exit 1
tar -xzf lua-resty-websocket-$ver.tar.gz || exit 1
mv openresty-lua-resty-websocket-* lua-resty-websocket-$ver || exit 1
@ -569,14 +579,14 @@ mv openresty-lua-resty-lock-* lua-resty-lock-$ver || exit 1
#################################
ver=0.03
ver=0.04
$root/util/get-tarball "https://github.com/openresty/lua-resty-lrucache/tarball/v$ver" -O "lua-resty-lrucache-$ver.tar.gz" || exit 1
tar -xzf lua-resty-lrucache-$ver.tar.gz || exit 1
mv openresty-lua-resty-lrucache-* lua-resty-lrucache-$ver || exit 1
#################################
ver=0.0.9
ver=0.1.0
$root/util/get-tarball "https://github.com/openresty/lua-resty-core/tarball/v$ver" -O "lua-resty-core-$ver.tar.gz" || exit 1
tar -xzf lua-resty-core-$ver.tar.gz || exit 1
mv openresty-lua-resty-core-* lua-resty-core-$ver || exit 1
@ -596,7 +606,6 @@ cd ..
cp $root/util/configure ./
cp $root/README.markdown ./
cp $root/util/install bundle/
cp $root/util/resty bundle/
find bundle -name '*~' -delete
cd $root

View File

@ -1,308 +0,0 @@
#!/usr/bin/env perl
# Copyright (C) Yichun Zhang (agentzh)
# TODO: port this script into the nginx core for greater flexibility
# and better performance.
use strict;
use warnings;
use File::Spec ();
use FindBin ();
use Getopt::Std qw( getopts );
use File::Temp qw( tempdir );
use POSIX qw( WNOHANG );
my %opts;
getopts("he:c:VI:", \%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}) {
my $cmd = "$nginx_path -V";
exec $cmd or die "Failed to run command \"$cmd\": $!\n";
}
my $lua_package_path_config = '';
if ($opts{I}) {
my $dir = $opts{I};
if (!-d $dir) {
die "Search directory $dir is not found.\n";
}
$lua_package_path_config = <<_EOC_;
lua_package_path "$dir/?.lua;;";
lua_package_cpath "$dir/?.so;;";
_EOC_
}
my $luafile;
if (!defined $opts{e}) {
$luafile = shift
or die qq{No Lua input file nor -e "" option specified.\n};
}
if (@ARGV) {
die "unknown arguments: @ARGV\n";
}
my $conns = $opts{c} || 64;
my @nameservers;
# try to read the nameservers used by the system resolver:
if (open my $in, "/etc/resolv.conf") {
while (<$in>) {
if (/^\s*nameserver\s+(\d+(?:\.\d+){3})(?:\s+|$)/) {
push @nameservers, $1;
if (@nameservers > 10) {
last;
}
}
}
close $in;
}
if (!@nameservers) {
# default to Google's open DNS servers
push @nameservers, "8.8.8.8", "8.8.4.4";
}
#warn "@nameservers\n";
my $prefix_dir = tempdir(CLEANUP => 1);
#warn "prefix dir: $prefix_dir\n";
my $logs_dir = File::Spec->catfile($prefix_dir, "logs");
mkdir $logs_dir or die "failed to mkdir $logs_dir: $!";
my $conf_dir = File::Spec->catfile($prefix_dir, "conf");
mkdir $conf_dir or die "failed to mkdir $conf_dir: $!";
my $chunk_name;
if (defined $opts{e}) {
$luafile = File::Spec->catfile($conf_dir, "a.lua");
open my $out, ">$luafile"
or die "Cannot open $luafile for writing: $!\n";
print $out $opts{e};
close $out;
$chunk_name = "=(command line -e)";
} else {
$chunk_name = "\@$luafile";
}
my $loader = <<_EOC_;
local gen
do
local fname = "$luafile"
local f = assert(io.open(fname, "r"))
local chunk = f:read("*a")
gen = assert(loadstring(chunk, "$chunk_name"))
end
_EOC_
my $env_list = '';
for my $var (sort keys %ENV) {
#warn $var;
$env_list .= "env $var;\n";
}
my $conf_file = File::Spec->catfile($conf_dir, "nginx.conf");
open my $out, ">$conf_file"
or die "Cannot open $conf_file for writing: $!\n";
print $out <<_EOC_;
daemon off;
master_process off;
worker_processes 1;
$env_list
error_log /dev/stderr warn;
#error_log /dev/stderr debug;
events {
worker_connections $conns;
}
http {
access_log off;
lua_socket_log_errors off;
resolver @nameservers;
$lua_package_path_config
init_by_lua '
local stdout = io.stdout
local ngx_null = ngx.null
local maxn = table.maxn
local unpack = unpack
local concat = table.concat
local expand_table
function expand_table(src, inplace)
local n = maxn(src)
local dst = inplace and src or {}
for i = 1, n do
local arg = src[i]
local typ = type(arg)
if arg == nil then
dst[i] = "nil"
elseif typ == "boolean" then
if arg then
dst[i] = "true"
else
dst[i] = "false"
end
elseif arg == ngx_null then
dst[i] = "null"
elseif typ == "table" then
dst[i] = expand_table(arg, false)
elseif typ ~= "string" then
dst[i] = tostring(arg)
else
dst[i] = arg
end
end
return concat(dst)
end
local function output(...)
local args = {...}
return stdout:write(expand_table(args, true))
end
ngx.print = output
ngx.say = function (...)
local ok, err = output(...)
if ok then
return output("\\\\n")
end
return ok, err
end
print = ngx.say
ngx.flush = function (...) return stdout:flush() end
-- we cannot close stdout here due to a bug in Lua:
ngx.eof = function (...) return true end
ngx.exit = os.exit
';
init_worker_by_lua '
local exit = os.exit
local stderr = io.stderr
local function handle_err(err)
if err then
err = string.gsub(err, "^init_worker_by_lua:%d+: ", "")
stderr:write(err, "\\\\n")
end
return exit(1)
end
local ok, err = pcall(function ()
if not ngx.config
or not ngx.config.ngx_lua_version
or ngx.config.ngx_lua_version < 9011
then
error("at least ngx_lua 0.9.12 is required")
end
$loader
-- print("calling timer.at...")
local ok, err = ngx.timer.at(0, function ()
-- io.stderr:write("timer firing")
local ok, err = pcall(gen)
if not ok then
return handle_err(err)
end
local rc = err
if rc and type(rc) ~= "number" then
return handle_err("bad return value of type " .. type(rc))
end
return exit(rc)
end)
if not ok then
return handle_err(err)
end
-- print("timer created")
end)
if not ok then
return handle_err(err)
end
';
}
_EOC_
close $out;
my $cmd = "$nginx_path -p $prefix_dir/";
my $child_pid;
sub sigint {
$SIG{INT} = \&sigint;
if ($child_pid) {
kill INT => $child_pid;
}
}
$SIG{INT} = \&sigint;
my $pid = fork();
if (!defined $pid) {
die "fork() failed: $!\n";
}
if ($pid == 0) { # child process
#warn "exec $cmd...";
exec $cmd or die "Failed to run command \"$cmd\": $!\n";
} else {
$child_pid = $pid;
waitpid($child_pid, 0);
my $rc = 0;
if (defined $?) {
$rc = ($? >> 8);
}
exit($rc);
}
sub usage {
my $rc = shift;
my $msg = <<_EOC_;
resty [-I dir] [-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.
-I dir Add dir to the search paths for Lua libraries.
-V print the underlying nginx version and configurations.
For bug reporting instructions, please see:
<http://openresty.org/#Community>
_EOC_
if ($rc == 0) {
print $msg;
exit(0);
}
warn $msg;
exit($rc);
}

View File

@ -1,7 +1,7 @@
#!/bin/bash
main_ver=1.7.7
minor_ver=1
minor_ver=2
version=$main_ver.$minor_ver
echo $version