Awesome Open Source
Awesome Open Source

Name

lua-resty-ntp - Get utc time from ntp server for ngx_lua and LuaJIT

Table of Contents

Description

This library requires the ngx_lua module, and LuaJIT 2.0.

Synopsis

    # 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           
            }
        }
    }

Author

Jason zhu (朱茂海) [email protected]

See Also


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Lua (41,980
Luajit (343
Ntp (172
Related Projects