Software /
code /
prosody-modules
Comparison
mod_persisthosts/mod_persisthosts.lua @ 2447:366fadb5c6e5
mod_persisthosts: Fire an event to allow other modules a chance to write to the new config file
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 18 Jan 2017 01:52:50 +0100 |
parent | 2446:c563f4d64302 |
comparison
equal
deleted
inserted
replaced
2446:c563f4d64302 | 2447:366fadb5c6e5 |
---|---|
16 local path = path_pattern:format(host); | 16 local path = path_pattern:format(host); |
17 if not stat(path) then | 17 if not stat(path) then |
18 local fh, err = io.open(path, "w"); | 18 local fh, err = io.open(path, "w"); |
19 if fh then | 19 if fh then |
20 fh:write(("VirtualHost%q\n"):format(host)); | 20 fh:write(("VirtualHost%q\n"):format(host)); |
21 module:fire_event("host-persisted", { host = host, file = fh }); | |
21 fh:close(); | 22 fh:close(); |
22 module:log("info", "Config file for host '%s' created", host); | 23 module:log("info", "Config file for host '%s' created", host); |
23 else | 24 else |
24 module:log("error", "Could not open '%s' for writing: %s", path, err or "duno"); | 25 module:log("error", "Could not open '%s' for writing: %s", path, err or "duno"); |
25 end | 26 end |