From 67144d911b344344f47991f19bd6a344cb5acdd3 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 22 Nov 2012 20:40:06 +0100 Subject: mod_http: Make module:http_url() aware of http_host --- plugins/mod_http.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua index 4f09716c..f386f870 100644 --- a/plugins/mod_http.lua +++ b/plugins/mod_http.lua @@ -55,7 +55,7 @@ function moduleapi.http_url(module, app_name, default_path) for port, services in pairs(ports) do local url = { scheme = (external_url.scheme or services[1].service.name); - host = (external_url.host or module.host); + host = (external_url.host or module:get_option_string("http_host", module.host)); port = tonumber(external_url.port) or port or 80; path = normalize_path(external_url.path or "/").. (get_base_path(module, app_name, default_path or "/"..app_name):sub(2)); -- cgit v1.2.3 From 565ea2bbe10267a1310c2efed6aaffecd59c6def Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 22 Nov 2012 20:59:20 +0000 Subject: modulemanager: Set module.reloading when a module is reloading, and when loading make the saved state available in module.saved_state (if any) --- core/modulemanager.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/modulemanager.lua b/core/modulemanager.lua index b0d54caa..4ba2c27e 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -111,7 +111,7 @@ local function do_unload_module(host, name) return true; end -local function do_load_module(host, module_name) +local function do_load_module(host, module_name, state) if not (host and module_name) then return nil, "insufficient-parameters"; elseif not hosts[host] and host ~= "*"then @@ -152,7 +152,8 @@ local function do_load_module(host, module_name) local _log = logger.init(host..":"..module_name); local api_instance = setmetatable({ name = module_name, host = host, - _log = _log, log = function (self, ...) return _log(...); end, event_handlers = new_multitable() } + _log = _log, log = function (self, ...) return _log(...); end, event_handlers = new_multitable(), + reloading = not not state, saved_state = state~=true and state or nil } , { __index = api }); local pluginenv = setmetatable({ module = api_instance }, { __index = _G }); @@ -176,6 +177,7 @@ local function do_load_module(host, module_name) log("warn", "Error loading module '%s' on '%s': %s", module_name, host, err or "nil"); end end + api_instance.reloading, api_instance.saved_state = nil, nil; if api_instance.host == "*" then if not api_instance.global then -- COMPAT w/pre-0.9 @@ -225,8 +227,9 @@ local function do_reload_module(host, name) end end + mod.module.reloading = true; do_unload_module(host, name); - local ok, err = do_load_module(host, name); + local ok, err = do_load_module(host, name, saved or true); if ok then mod = get_module(host, name); if module_has_method(mod, "restore") then -- cgit v1.2.3