view mod_reload_modules/mod_reload_modules.lua @ 340:5d306466f3f6

mod_auth_dovecot: Use hash of vhost as PID to pass to dovecot - the ID must be unique per process, whereas we make a connection per vhost.
author Matthew Wild <mwild1@gmail.com>
date Mon, 14 Feb 2011 01:27:35 +0000
parents 524f22ef2c2b
children aad0b2df9e6b
line wrap: on
line source

local mm = require "core.modulemanager";

local function reload_module(name)
	local ok, err = mm.reload(module.host, name);
	if ok then
		module:log("debug", "Reloaded %s", name);
	else
		module:log("error", "Failed to reload %s: %s", name, err);
	end
end

prosody.events.add_handler("config-reloaded", function ()
	local modules = module:get_option_array("reload_modules");
	if not modules then
		module:log("warn", "No modules listed in the config to reload - set reload_modules to a list");
		return;
	end
	for _, module in ipairs(modules) do
		reload_module(module);
	end
end);