Changeset

12294:81f147ddc4ab

prosody: Move last cleanup and shutdown code into util.startup
author Kim Alvefur <zash@zash.se>
date Tue, 01 Jan 2019 16:42:52 +0100
parents 12293:145cb8305c67
children 12295:e22afa09ebf2
files prosody util/startup.lua
diffstat 2 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/prosody	Thu Feb 17 01:41:57 2022 +0100
+++ b/prosody	Tue Jan 01 16:42:52 2019 +0100
@@ -78,18 +78,6 @@
 	end
 end
 
-local function cleanup()
-	prosody.log("info", "Shutdown status: Cleaning up");
-	prosody.events.fire_event("server-cleanup");
-end
-
 loop();
 
-prosody.log("info", "Shutting down...");
-cleanup();
-prosody.events.fire_event("server-stopped");
-prosody.log("info", "Shutdown complete");
-
-prosody.log("debug", "Shutdown reason was: %s", prosody.shutdown_reason or "not specified");
-prosody.log("debug", "Exiting with status code: %d", prosody.shutdown_code or 0);
-os.exit(prosody.shutdown_code, true);
+startup.shutdown();
--- a/util/startup.lua	Thu Feb 17 01:41:57 2022 +0100
+++ b/util/startup.lua	Tue Jan 01 16:42:52 2019 +0100
@@ -624,6 +624,22 @@
 	end
 end
 
+function startup.cleanup()
+	prosody.log("info", "Shutdown status: Cleaning up");
+	prosody.events.fire_event("server-cleanup");
+end
+
+function startup.shutdown()
+	prosody.log("info", "Shutting down...");
+	startup.cleanup();
+	prosody.events.fire_event("server-stopped");
+	prosody.log("info", "Shutdown complete");
+
+	prosody.log("debug", "Shutdown reason was: %s", prosody.shutdown_reason or "not specified");
+	prosody.log("debug", "Exiting with status code: %d", prosody.shutdown_code or 0);
+	os.exit(prosody.shutdown_code);
+end
+
 -- prosodyctl only
 function startup.prosodyctl()
 	prosody.process_type = "prosodyctl";