[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Xavante / Compat-5.1: reloading a module?
- From: William Trenker <wtrenker@...>
- Date: Tue, 2 Aug 2005 15:26:44 -0400
What is the "proper" way to reload a module on the fly? I am running
Xavante and have a custom handler that uses a module. I want to be
able to change the module's source code and have the changes re-loaded
automatically without stopping Xavante.
I've been doing this:
--- myXavanteHandler.lua ---
module("myXavanteHandler")
local function myHandler(req, res, param)
package.loaded.myModule = nil
require"myModule"
res.content = myModule.html(req.built_url)
return res
end
function makeHandler (params)
return function (req, res)
return myHandler(req, res, params[1])
end
end
--- end code ---
--- myModule.lua ---
module("myModule")
function html(txt)
return "txt = "..txt.."<br />"
end
--- end code ---
The net effect is that when I change the code in myModule.lua, it will
be reloaded the next time the handler is called.
But is setting package.loaded.x to nil the design-intended way to
trigger a reload? Will this cause problems with package.preload?
Thanks,
Bill