--- And lock now...
-lock_globals();
-
-eventmanager.fire_event("server-started");
-
--- Error handler for errors that make it this far
-local function catch_uncaught_error(err)
- if err:match("%d*: interrupted!$") then
- return "quitting";
+function prepare_to_start()
+ log("debug", "Prosody is using the %s backend for connection handling", server.get_backend());
+ -- Signal to modules that we are ready to start
+ eventmanager.fire_event("server-starting");
+ prosody.events.fire_event("server-starting");
+
+ -- start listening on sockets
+ prosody.net_activate_ports("c2s", "xmppclient", {5222});
+ prosody.net_activate_ports("s2s", "xmppserver", {5269});
+ prosody.net_activate_ports("component", "xmppcomponent", {}, "tcp");
+ prosody.net_activate_ports("legacy_ssl", "xmppclient", {}, "ssl");
+
+ prosody.start_time = os.time();
+end
+
+function init_global_protection()
+ -- Catch global accesses
+ 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;
+ };
+
+ function prosody.unlock_globals()
+ setmetatable(_G, nil);