prosody

changeset 1026
e640df2e4e9b
parent 1017
6556a9db3822
child 1084
422be8f8911c
equal deleted inserted replaced
1024:1bcc8ca57a7c 1026:e640df2e4e9b
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
222 end 225 end
223 end 226 end
224 end 227 end
225 228
226 server.closeall(); 229 server.closeall();
230
231 eventmanager.fire_event("server-stopped");

mercurial