Skip to content

centos-bz/lua-resty-ntp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

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 (朱茂海) admin@centos.bz

See Also

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages