lua-resty-ntp - Get utc time from ntp server for ngx_lua and LuaJIT
This library requires the ngx_lua module, and LuaJIT 2.0.
# nginx.conf:
lua_package_path "/path/to/lua-resty-string/lib/?.lua;;";
resolver 119.29.29.29;
server {
location = /test {
content_by_lua_block {
local ntp = require "resty.ntp"
-- ntp.utctime(ntp_server, retry , timeout)
local utctime,err = ntp.utctime("pool.ntp.org", 3, 1000)
if utctime then
ngx.say("utctime:",utctime)
else
ngx.say("failed to get utctime: ",err)
end
}
}
}
Jason zhu (朱茂海) [email protected]
- the ngx_lua module: http://wiki.nginx.org/HttpLuaModule