Mercurial > prosody-modules
comparison mod_reload_modules/mod_reload_modules.lua @ 313:524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 08 Jan 2011 18:16:14 +0000 |
parents | |
children | aad0b2df9e6b |
comparison
equal
deleted
inserted
replaced
312:31deafcbf623 | 313:524f22ef2c2b |
---|---|
1 local mm = require "core.modulemanager"; | |
2 | |
3 local function reload_module(name) | |
4 local ok, err = mm.reload(module.host, name); | |
5 if ok then | |
6 module:log("debug", "Reloaded %s", name); | |
7 else | |
8 module:log("error", "Failed to reload %s: %s", name, err); | |
9 end | |
10 end | |
11 | |
12 prosody.events.add_handler("config-reloaded", function () | |
13 local modules = module:get_option_array("reload_modules"); | |
14 if not modules then | |
15 module:log("warn", "No modules listed in the config to reload - set reload_modules to a list"); | |
16 return; | |
17 end | |
18 for _, module in ipairs(modules) do | |
19 reload_module(module); | |
20 end | |
21 end); |