Mercurial > prosody-hg
comparison plugins/mod_posix.lua @ 5175:fabaed7418a6
mod_posix: Remove console and stdout logging sinks before daemonizing
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 10 Nov 2012 23:39:22 +0100 |
| parents | 5243b74a4cbb |
| children | add9ad38208e |
comparison
equal
deleted
inserted
replaced
| 5173:b22d24b5a89a | 5175:fabaed7418a6 |
|---|---|
| 134 module:log("warn", "The 'no_daemonize' option is now replaced by 'daemonize'"); | 134 module:log("warn", "The 'no_daemonize' option is now replaced by 'daemonize'"); |
| 135 module:log("warn", "Update your config from 'no_daemonize = %s' to 'daemonize = %s'", tostring(no_daemonize), tostring(daemonize)); | 135 module:log("warn", "Update your config from 'no_daemonize = %s' to 'daemonize = %s'", tostring(no_daemonize), tostring(daemonize)); |
| 136 end | 136 end |
| 137 end | 137 end |
| 138 | 138 |
| 139 local function remove_log_sinks() | |
| 140 local lm = require "core.loggingmanager"; | |
| 141 lm.register_sink_type("console", nil); | |
| 142 lm.register_sink_type("stdout", nil); | |
| 143 lm.reload_logging(); | |
| 144 end | |
| 145 | |
| 139 if daemonize then | 146 if daemonize then |
| 140 local function daemonize_server() | 147 local function daemonize_server() |
| 148 remove_log_sinks(); | |
| 141 local ok, ret = pposix.daemonize(); | 149 local ok, ret = pposix.daemonize(); |
| 142 if not ok then | 150 if not ok then |
| 143 module:log("error", "Failed to daemonize: %s", ret); | 151 module:log("error", "Failed to daemonize: %s", ret); |
| 144 elseif ret and ret > 0 then | 152 elseif ret and ret > 0 then |
| 145 os.exit(0); | 153 os.exit(0); |
