X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=prosody;h=2febe4d8b7f0dd920ff601d1b80f0d1e0e99b384;hb=c0c83da1a045258025a2825f437af7a5e602c9c9;hp=b270881c88d415fb3b44dc4c0b4a5d153e5cbe64;hpb=76e1de7286742fa6dc8b42c7e5fba6c32e39caac;p=prosody.git diff --git a/prosody b/prosody index b270881c..2febe4d8 100755 --- a/prosody +++ b/prosody @@ -38,7 +38,7 @@ do -- Use lfs? Make a new conf/ dir? local ok, level, err = config.load((CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); if not ok then - print(""); + print("\n"); print("**************************"); if level == "parser" then print("A problem occured while reading the config file "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); @@ -59,22 +59,22 @@ do end end -log = require "util.logger".init("general"); - --- Disable log output, needs to read from config --- require "util.logger".setwriter(function () end); +--- Initialize logging +require "core.loggingmanager" +--- Check runtime dependencies require "util.dependencies" +--- Load socket framework local server = require "net.server" + -- Maps connections to sessions -- sessions = {}; hosts = {}; --- Load and initialise core modules -- - +--- Load and initialise core modules require "util.import" require "core.xmlhandlers" require "core.rostermanager" @@ -114,8 +114,37 @@ end); ----------- End of out-of-place code -------------- +-- Function to reload the config file +function prosody_reload_config() + log("info", "Reloading configuration file"); + eventmanager.fire_event("reloading-config"); + local ok, level, err = config.load((rawget(_G, "CFG_CONFIGDIR") or ".").."/prosody.cfg.lua"); + if not ok then + if level == "parser" then + log("error", "There was an error parsing the configuration file: %s", tostring(err)); + elseif level == "file" then + log("error", "Couldn't read the config file when trying to reload: %s", tostring(err)); + end + end +end + +-- Function to reopen logfiles +function prosody_reopen_logfiles() + log("info", "Re-opening log files"); + eventmanager.fire_event("reopen-log-files"); -- Handled by appropriate log sinks +end + +-- Function to initiate prosody shutdown +function prosody_shutdown(reason) + log("info", "Shutting down: %s", reason or "unknown reason"); + eventmanager.fire_event("server-stopping", { reason = reason }); + server.setquitting(true); +end + +-- Signal to modules that we are ready to start eventmanager.fire_event("server-starting"); +-- Load SSL settings from config, and create a ctx table local global_ssl_ctx = ssl and config.get("*", "core", "ssl"); if global_ssl_ctx then local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none"; }; @@ -147,20 +176,11 @@ end net_activate_ports("c2s", "xmppclient", {5222}, (global_ssl_ctx and "tls") or "tcp"); net_activate_ports("s2s", "xmppserver", {5269}, "tcp"); +net_activate_ports("component", "xmppcomponent", {}, "tcp"); net_activate_ports("legacy_ssl", "xmppclient", {}, "ssl"); -if config.get("*", "core", "console_enabled") then - if cl.get("console") then - cl.start("console", { interface = config.get("*", "core", "console_interface") or "127.0.0.1" }) - else - log("error", "Console is enabled, but the console module appears not to be loaded"); - end -end - --- Global function to initiate prosody shutdown -function prosody_shutdown(reason) - log("info", "Shutting down: %s", reason or "unknown reason"); - server.setquitting(true); +if cl.get("console") then + cl.start("console", { interface = config.get("*", "core", "console_interface") or "127.0.0.1" }) end -- Catch global accesses -- @@ -198,11 +218,16 @@ while select(2, xpcall(server.loop, catch_uncaught_error)) ~= "quitting" do socket.sleep(0.2); end +log("info", "Shutdown status: Cleaning up"); +eventmanager.fire_event("server-cleanup"); + -- Ok, we're quitting I know, but we -- need to do some tidying before we go :) server.setquitting(false); +log("info", "Shutdown status: Closing all active sessions"); for hostname, host in pairs(hosts) do + log("debug", "Shutdown status: Closing client connections for %s", hostname) if host.sessions then for username, user in pairs(host.sessions) do for resource, session in pairs(user.sessions) do @@ -212,6 +237,7 @@ for hostname, host in pairs(hosts) do end end + log("debug", "Shutdown status: Closing outgoing s2s connections from %s", hostname); if host.s2sout then for remotehost, session in pairs(host.s2sout) do if session.close then @@ -223,4 +249,10 @@ for hostname, host in pairs(hosts) do end end +log("info", "Shutdown status: Closing all server connections"); server.closeall(); + +server.setquitting(true); + +eventmanager.fire_event("server-stopped"); +log("info", "Shutdown status: Complete!");