From d7bdca2190e06f7062e0b0060d02eb33e59805ae Mon Sep 17 00:00:00 2001 From: Tangent Date: Sun, 13 Sep 2026 16:39:28 -0600 Subject: [PATCH] what the fuck OpenResty --- config.lua | 3 ++- nginx.conf | 1 + path_fix.lua | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 path_fix.lua diff --git a/config.lua b/config.lua index e63bdfd..2643af2 100644 --- a/config.lua +++ b/config.lua @@ -3,5 +3,6 @@ local config = require("lapis.config") config("development", { server = "nginx", code_cache = "off", - num_workers = "1" + num_workers = "1", + port = "8080", }) diff --git a/nginx.conf b/nginx.conf index 4e7b83d..550a6fc 100644 --- a/nginx.conf +++ b/nginx.conf @@ -22,6 +22,7 @@ http { default_type text/html; content_by_lua_block { require("lapis").serve("app") + -- require("path_fix") } } diff --git a/path_fix.lua b/path_fix.lua new file mode 100644 index 0000000..2c9d624 --- /dev/null +++ b/path_fix.lua @@ -0,0 +1,16 @@ +-- WARNING this works in LuaJIT but fails in OpenResty; it somehow ignores the path + +-- there is no way to find the correct load path / current user from OpenResty +local CODE_PATH = "/Users/tangent/.luarocks/share/lua/5.1/" + +local lapis +local success, error_message = pcall(function() return require("lapis") end) + +if success then + lapis = error_message +else + package.path = package.path .. ";" .. CODE_PATH .. "?.lua;" .. CODE_PATH .. "?/init.lua" + lapis = require("lapis") +end + +lapis.serve("app")