leafo / lapis

A web framework for Lua and OpenResty written in MoonScript
http://leafo.net/lapis/
MIT License
3.12k stars 247 forks source link

How do you turn on lua_code_cache via lapis? #727

Closed axelthat closed 3 years ago

axelthat commented 3 years ago

In app.lua I have following:

local lapis = require("lapis")
local config = require("lapis.config")
local app = lapis.Application()

config({"development", "production"}, {code_cache = "on"})

local function getController()
    return "Welcome to Lapis " .. require("lapis.version")
end

app:get("/", getController)

return app

As you can see I have code_cache set to on. But when I do lapis server, the compiled version of NGINX configuration has lua_code_cache off;. How do I fix this?

axelthat commented 3 years ago

My bad, I didn't read the docs thoroughly. Actually you have to create config.lua inside your root project directory and add all the configs there.

Example: touch <myproject>/config.lua

And add following contents:

local config = require("lapis.config")
config({"development", "production"}, {code_cache = "on"})

And remove the config details from app.lua