Mercurial > prosody-hg
comparison plugins/mod_posix.lua @ 1691:e9b589dae393
mod_posix: Updated to use module:get_option instead of configmanager
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Thu, 13 Aug 2009 16:55:44 +0500 |
| parents | 95698f021c5d |
| children | 45a81d6d8777 |
comparison
equal
deleted
inserted
replaced
| 1690:b675ae5b4c91 | 1691:e9b589dae393 |
|---|---|
| 15 local signal = select(2, pcall(require, "util.signal")); | 15 local signal = select(2, pcall(require, "util.signal")); |
| 16 if type(signal) == "string" then | 16 if type(signal) == "string" then |
| 17 module:log("warn", "Couldn't load signal library, won't respond to SIGTERM"); | 17 module:log("warn", "Couldn't load signal library, won't respond to SIGTERM"); |
| 18 end | 18 end |
| 19 | 19 |
| 20 local config_get = require "core.configmanager".get; | |
| 21 local logger_set = require "util.logger".setwriter; | 20 local logger_set = require "util.logger".setwriter; |
| 22 | 21 |
| 23 local prosody = _G.prosody; | 22 local prosody = _G.prosody; |
| 24 | 23 |
| 25 module.host = "*"; -- we're a global module | 24 module.host = "*"; -- we're a global module |
| 26 | 25 |
| 27 -- Don't even think about it! | 26 -- Don't even think about it! |
| 28 module:add_event_hook("server-starting", function () | 27 module:add_event_hook("server-starting", function () |
| 29 if pposix.getuid() == 0 and not config_get("*", "core", "run_as_root") then | 28 if pposix.getuid() == 0 and not module:get_option("run_as_root") then |
| 30 module:log("error", "Danger, Will Robinson! Prosody doesn't need to be run as root, so don't do it!"); | 29 module:log("error", "Danger, Will Robinson! Prosody doesn't need to be run as root, so don't do it!"); |
| 31 module:log("error", "For more information on running Prosody as root, see http://prosody.im/doc/root"); | 30 module:log("error", "For more information on running Prosody as root, see http://prosody.im/doc/root"); |
| 32 prosody.shutdown("Refusing to run as root"); | 31 prosody.shutdown("Refusing to run as root"); |
| 33 end | 32 end |
| 34 end); | 33 end); |
| 44 | 43 |
| 45 local function write_pidfile() | 44 local function write_pidfile() |
| 46 if pidfile_written then | 45 if pidfile_written then |
| 47 remove_pidfile(); | 46 remove_pidfile(); |
| 48 end | 47 end |
| 49 local pidfile = config_get("*", "core", "pidfile"); | 48 local pidfile = module:get_option("pidfile"); |
| 50 if pidfile then | 49 if pidfile then |
| 51 local pf, err = io.open(pidfile, "w+"); | 50 local pf, err = io.open(pidfile, "w+"); |
| 52 if not pf then | 51 if not pf then |
| 53 module:log("error", "Couldn't write pidfile; %s", err); | 52 module:log("error", "Couldn't write pidfile; %s", err); |
| 54 else | 53 else |
| 74 end | 73 end |
| 75 end; | 74 end; |
| 76 end | 75 end |
| 77 require "core.loggingmanager".register_sink_type("syslog", syslog_sink_maker); | 76 require "core.loggingmanager".register_sink_type("syslog", syslog_sink_maker); |
| 78 | 77 |
| 79 if not config_get("*", "core", "no_daemonize") then | 78 if not module:get_option("no_daemonize") then |
| 80 local function daemonize_server() | 79 local function daemonize_server() |
| 81 local ok, ret = pposix.daemonize(); | 80 local ok, ret = pposix.daemonize(); |
| 82 if not ok then | 81 if not ok then |
| 83 module:log("error", "Failed to daemonize: %s", ret); | 82 module:log("error", "Failed to daemonize: %s", ret); |
| 84 elseif ret and ret > 0 then | 83 elseif ret and ret > 0 then |
