Changeset

1561:04442f3ebe40

prosody: Send friendly text with system-shutdown stream error
author Matthew Wild <mwild1@gmail.com>
date Sat, 18 Jul 2009 18:51:04 +0100
parents 1560:a8c14a350de5
children 1562:2b8674e87a24
files prosody
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/prosody	Sat Jul 18 18:49:54 2009 +0100
+++ b/prosody	Sat Jul 18 18:51:04 2009 +0100
@@ -119,6 +119,7 @@
 	-- Function to initiate prosody shutdown
 	function prosody.shutdown(reason)
 		log("info", "Shutting down: %s", reason or "unknown reason");
+		prosody.shutdown_reason = reason;
 		prosody.events.fire_event("server-stopping", {reason = reason});
 		server.setquitting(true);
 	end
@@ -278,10 +279,14 @@
 	for hostname, host in pairs(hosts) do
 		log("debug", "Shutdown status: Closing client connections for %s", hostname)
 		if host.sessions then
+			local reason = { condition = "system-shutdown", text = "Server is shutting down" };
+			if prosody.shutdown_reason then
+				reason.text = reason.text..": "..prosody.shutdown_reason;
+			end
 			for username, user in pairs(host.sessions) do
 				for resource, session in pairs(user.sessions) do
 					log("debug", "Closing connection for %s@%s/%s", username, hostname, resource);
-					session:close("system-shutdown");
+					session:close(reason);
 				end
 			end
 		end