Skip to content

Conversation

thibaultcha
Copy link
Member

I hereby granted the copyright of the changes in this pull request
to the authors of this lua-resty-core project.

Sister PR of openresty/lua-nginx-module#1259

FFI-based API for dynamic NGINX configuration via a new configure_by_lua phase.

Synopsis:

http {
    configure_by_lua_block {
        local ngx_configure = require "ngx.configure"

        -- hard-coded, but could be retrieved from I/O or env
        local shms = {
            { "dogs", "12k" },
            { "cats", "24k" }
        }

        -- create shms
        for _, shm in ipairs(shms) do
            ngx_configure.shared_dict(shm[1], shm[2])
        end

        -- conditionally expose env variables for workers
        ngx_configure.env("PROXY_PASS_URL")

        -- configure the Lua VM
        ngx_configure.max_pending_timers(1024)
        ngx_configure.max_running_timers(128)
    }

    init_by_lua_block {
        ngx.shared.dogs:set("hello", true)
    }
}

@thibaultcha thibaultcha force-pushed the feat/configure-by-lua branch from 41ca7d8 to 728bfe9 Compare February 18, 2018 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant