# HG changeset patch # User Kim Alvefur # Date 1546357372 -3600 # Node ID 81f147ddc4ab0d5650ebb4aa74fd8e686efc6082 # Parent 145cb8305c677a8b7620d38fe28443b2c579f86b prosody: Move last cleanup and shutdown code into util.startup diff -r 145cb8305c67 -r 81f147ddc4ab prosody --- 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(); diff -r 145cb8305c67 -r 81f147ddc4ab util/startup.lua --- 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";