158 end |
158 end |
159 |
159 |
160 -- Global function to initiate prosody shutdown |
160 -- Global function to initiate prosody shutdown |
161 function prosody_shutdown(reason) |
161 function prosody_shutdown(reason) |
162 log("info", "Shutting down: %s", reason or "unknown reason"); |
162 log("info", "Shutting down: %s", reason or "unknown reason"); |
|
163 eventmanager.fire_event("server-stopping", { reason = reason }); |
163 server.setquitting(true); |
164 server.setquitting(true); |
164 end |
165 end |
165 |
166 |
166 -- Catch global accesses -- |
167 -- Catch global accesses -- |
167 local locked_globals_mt = { __index = function (t, k) error("Attempt to read a non-existent global '"..k.."'", 2); end, __newindex = function (t, k, v) error("Attempt to set a global: "..tostring(k).." = "..tostring(v), 2); end } |
168 local locked_globals_mt = { __index = function (t, k) error("Attempt to read a non-existent global '"..k.."'", 2); end, __newindex = function (t, k, v) error("Attempt to set a global: "..tostring(k).." = "..tostring(v), 2); end } |
195 end |
196 end |
196 |
197 |
197 while select(2, xpcall(server.loop, catch_uncaught_error)) ~= "quitting" do |
198 while select(2, xpcall(server.loop, catch_uncaught_error)) ~= "quitting" do |
198 socket.sleep(0.2); |
199 socket.sleep(0.2); |
199 end |
200 end |
|
201 |
|
202 eventmanager.fire_event("server-cleanup"); |
200 |
203 |
201 -- Ok, we're quitting I know, but we |
204 -- Ok, we're quitting I know, but we |
202 -- need to do some tidying before we go :) |
205 -- need to do some tidying before we go :) |
203 server.setquitting(false); |
206 server.setquitting(false); |
204 |
207 |