Software /
code /
prosody-modules
Annotate
mod_reload_modules/mod_reload_modules.lua @ 491:5b3db688213d
mod_ircd: Fixed nick change logic (thanks mva), so that the self nick-change "flag" is removed properly, improved the logic to use verse's room_mt:change_nick (thanks Zash) yet to be pushed into main, added squished verse with the meta method included.
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Fri, 02 Dec 2011 20:53:09 +0000 |
parent | 313:524f22ef2c2b |
child | 502:aad0b2df9e6b |
rev | line source |
---|---|
313
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local mm = require "core.modulemanager"; |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local function reload_module(name) |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 local ok, err = mm.reload(module.host, name); |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 if ok then |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 module:log("debug", "Reloaded %s", name); |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 else |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 module:log("error", "Failed to reload %s: %s", name, err); |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 end |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 end |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 prosody.events.add_handler("config-reloaded", function () |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 local modules = module:get_option_array("reload_modules"); |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 if not modules then |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 module:log("warn", "No modules listed in the config to reload - set reload_modules to a list"); |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 return; |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 end |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 for _, module in ipairs(modules) do |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 reload_module(module); |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 end |
524f22ef2c2b
mod_reload_modules: Module to, erm, reload modules, on SIGHUP/config reload
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 end); |