resty: more improvements.

* made ngx.exit() an alias of os.exit().
* made the exit status code right for the wrapper process.
* require at least ngx_lua 0.9.12 to prevent memory bugs in older
  versions.
* suppressed a debugging output line.
This commit is contained in:
Yichun Zhang (agentzh) 2014-08-20 22:02:40 -07:00
parent bb71a30a68
commit cf8c075e79
3 changed files with 17 additions and 5 deletions

View File

@ -335,7 +335,7 @@ mv openresty-drizzle-nginx-module-* drizzle-nginx-module-$ver || exit 1
################################# #################################
ver=0.9.12rc1 ver=0.9.12rc2
$root/util/get-tarball "https://github.com/openresty/lua-nginx-module/tarball/v$ver" -O lua-nginx-module-$ver.tar.gz || exit 1 $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 tar -xzf lua-nginx-module-$ver.tar.gz || exit 1
mv openresty-lua-nginx-module-* ngx_lua-$ver || exit 1 mv openresty-lua-nginx-module-* ngx_lua-$ver || exit 1

View File

@ -76,7 +76,7 @@ if (!@nameservers) {
push @nameservers, "8.8.8.8", "8.8.4.4"; push @nameservers, "8.8.8.8", "8.8.4.4";
} }
warn "@nameservers\n"; #warn "@nameservers\n";
my $prefix_dir = tempdir(CLEANUP => 1); my $prefix_dir = tempdir(CLEANUP => 1);
#warn "prefix dir: $prefix_dir\n"; #warn "prefix dir: $prefix_dir\n";
@ -187,6 +187,7 @@ $lua_package_path_config
ngx.flush = function (...) return stdout:flush() end ngx.flush = function (...) return stdout:flush() end
-- we cannot close stdout here due to a bug in Lua: -- we cannot close stdout here due to a bug in Lua:
ngx.eof = function (...) return true end ngx.eof = function (...) return true end
ngx.exit = os.exit
'; ';
init_worker_by_lua ' init_worker_by_lua '
@ -196,12 +197,19 @@ $lua_package_path_config
local function handle_err(err) local function handle_err(err)
if err then if err then
err = string.gsub(err, "^init_worker_by_lua:%d+: ", "") err = string.gsub(err, "^init_worker_by_lua:%d+: ", "")
stderr:write(err) stderr:write(err, "\\\\n")
end end
return exit(1) return exit(1)
end end
local ok, err = pcall(function () 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 $loader
-- print("calling timer.at...") -- print("calling timer.at...")
local ok, err = ngx.timer.at(0, function () local ok, err = ngx.timer.at(0, function ()
@ -256,7 +264,11 @@ if ($pid == 0) { # child process
} else { } else {
$child_pid = $pid; $child_pid = $pid;
waitpid($child_pid, 0); waitpid($child_pid, 0);
exit($? || 0); my $rc = 0;
if (defined $?) {
$rc = ($? >> 8);
}
exit($rc);
} }
sub usage { sub usage {

View File

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