After Apache has failed me miserably, I decided to go the OpenResty route. So far, the Lua code is executing, however I opted to separate the generation in to multiple modules, to make the code more readable.
-- Define modules table
local modules = {
head = require("head"),
header = require("scripts.header"),
leftNav = require(".scripts.leftnav")
}
I've tried several methods of requiring files; - I've taken one file out of the /scripts/ directory, and moved it to the root directory, file cannot be found - I've tried referencing the /scripts/ directory with/out a period beforehand and all is to no avail. The modules simply aren't found.
Is there some kind of special trick I need to find these files?
Here is an excerpt from the error log:
stack traceback:
coroutine 0:
[C]: in function 'require'
./html/mailarchive/index.lua:10: in function <./html/mailarchive/index.lua:1>, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2017/05/12 10:26:13 [error] 113864#120792: *14 lua entry thread aborted: runtime error: ./html/mailarchive/index.lua:10: module 'head' not found:
no field package.preload['head']
no file './site/lualib/head.lua'
no file './site/lualib/head/init.lua'
no file './lualib/head.lua'
no file './lualib/head/init.lua'
no file '.\head.lua'
no file 'C:\nginx\lualib\head.lua'
no file 'C:\nginx\lua\head.lua'
no file 'C:\nginx\lua\head\init.lua'
no file 'C:\Program Files (x86)\Lua\5.1\lua\head.luac'
no file './site/lualib/head.so'
no file './lualib/head.so'
no file '.\head.dll'
no file 'C:\nginx\lualib\head.so'
no file 'C:\nginx\head.dll'
no file 'C:\nginx\loadall.dll'
stack traceback:
coroutine 0:
[C]: in function 'require'
./html/mailarchive/index.lua:10: in function <./html/mailarchive/index.lua:1>, client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost", referrer: "http://localhost/"
After some more researching, I found that using OpenResty, the period ( . ) doesn't refer to the current directory the executing script is located in, rather it refers to the directory that nginx is working in - in my case C:\nginx.
With this in mind, changing my resource locators from:
require(".scripts.head")
require(".scripts.header")
(...)
to
require(".html.mailarchive.scripts.head")
require(".html.mailarchive.scripts.header")
(...)
did the trick.
The new paths correlate to C:\nginx\html\mailarchive\scripts\head.lua, etc.