mod_saslauth: Make service_name configurable for CyrusSASL users.
[prosody.git] / plugins / mod_posix.lua
index 5f7dfc5b1884e9c8b857b851c1aa43764b936c4f..95b950347476292956d264e51bd2748f527e7a27 100644 (file)
@@ -102,7 +102,17 @@ function syslog_sink_maker(config)
 end
 require "core.loggingmanager".register_sink_type("syslog", syslog_sink_maker);
 
-if not module:get_option("no_daemonize") then
+local daemonize = module:get_option("daemonize");
+if daemonize == nil then
+       local no_daemonize = module:get_option("no_daemonize"); --COMPAT w/ 0.5
+       daemonize = not no_daemonize;
+       if no_daemonize ~= nil then
+               module:log("warn", "The 'no_daemonize' option is now replaced by 'daemonize'");
+               module:log("warn", "Update your config from 'no_daemonize = %s' to 'daemonize = %s'", tostring(no_daemonize), tostring(daemonize));
+       end
+end
+
+if daemonize then
        local function daemonize_server()
                local ok, ret = pposix.daemonize();
                if not ok then
@@ -126,6 +136,7 @@ module:add_event_hook("server-stopped", remove_pidfile);
 if signal.signal then
        signal.signal("SIGTERM", function ()
                module:log("warn", "Received SIGTERM");
+               signal.signal("SIGTERM", function () end); -- Fixes us getting into some kind of loop
                prosody.unlock_globals();
                prosody.shutdown("Received SIGTERM");
                prosody.lock_globals();
@@ -136,4 +147,12 @@ if signal.signal then
                prosody.reload_config();
                prosody.reopen_logfiles();
        end);
+       
+       signal.signal("SIGINT", function ()
+               module:log("info", "Received SIGINT");
+               signal.signal("SIGINT", function () end); -- Fix to not loop
+               prosody.unlock_globals();
+               prosody.shutdown("Received SIGINT");
+               prosody.lock_globals();
+       end);
 end