Changeset

8692:a55574754e5f

configmanager: Move firing of the 'config-reloaded' event into util.startup (fixes #1117)
author Kim Alvefur <zash@zash.se>
date Sun, 25 Mar 2018 17:02:00 +0200
parents 8691:564e2c63e0d4
children 8693:6e24a69b03af
files core/configmanager.lua util/startup.lua
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/core/configmanager.lua	Sun Mar 25 12:45:24 2018 +0100
+++ b/core/configmanager.lua	Sun Mar 25 17:02:00 2018 +0200
@@ -11,8 +11,6 @@
       setmetatable, rawget, rawset, io, error, dofile, type, pairs;
 local format, math_max = string.format, math.max;
 
-local fire_event = prosody and prosody.events.fire_event or function () end;
-
 local envload = require"util.envload".envload;
 local deps = require"util.dependencies";
 local resolve_relative_path = require"util.paths".resolve_relative_path;
@@ -86,11 +84,6 @@
 			f:close();
 			if ok then
 				config = new_config;
-				fire_event("config-reloaded", {
-					filename = filename,
-					format = config_format,
-					config = config
-				});
 			end
 			return ok, "parser", err;
 		end
--- a/util/startup.lua	Sun Mar 25 12:45:24 2018 +0100
+++ b/util/startup.lua	Sun Mar 25 17:02:00 2018 +0200
@@ -229,6 +229,11 @@
 			elseif level == "file" then
 				log("error", "Couldn't read the config file when trying to reload: %s", tostring(err));
 			end
+		else
+			prosody.events.fire_event("config-reloaded", {
+				filename = prosody.config_file,
+				config = config.getconfig(),
+			});
 		end
 		return ok, (err and tostring(level)..": "..tostring(err)) or nil;
 	end