Software /
code /
prosody
Comparison
plugins/mod_posix.lua @ 1238:f4c08caca3e7
mod_posix: Use global prosody object
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 30 May 2009 14:05:42 +0100 |
parent | 1119:61a011ebe243 |
child | 1522:569d58d21612 |
comparison
equal
deleted
inserted
replaced
1237:a30ca0d0df38 | 1238:f4c08caca3e7 |
---|---|
10 end | 10 end |
11 | 11 |
12 local config_get = require "core.configmanager".get; | 12 local config_get = require "core.configmanager".get; |
13 local logger_set = require "util.logger".setwriter; | 13 local logger_set = require "util.logger".setwriter; |
14 | 14 |
15 local prosody = _G.prosody; | |
16 | |
15 module.host = "*"; -- we're a global module | 17 module.host = "*"; -- we're a global module |
16 | 18 |
17 -- Don't even think about it! | 19 -- Don't even think about it! |
18 module:add_event_hook("server-starting", function () | 20 module:add_event_hook("server-starting", function () |
19 if pposix.getuid() == 0 and not config_get("*", "core", "run_as_root") then | 21 if pposix.getuid() == 0 and not config_get("*", "core", "run_as_root") then |
20 module:log("error", "Danger, Will Robinson! Prosody doesn't need to be run as root, so don't do it!"); | 22 module:log("error", "Danger, Will Robinson! Prosody doesn't need to be run as root, so don't do it!"); |
21 module:log("error", "For more information on running Prosody as root, see http://prosody.im/doc/root"); | 23 module:log("error", "For more information on running Prosody as root, see http://prosody.im/doc/root"); |
22 _G.prosody_shutdown("Refusing to run as root"); | 24 prosody.shutdown("Refusing to run as root"); |
23 end | 25 end |
24 end); | 26 end); |
25 | 27 |
26 local pidfile_written; | 28 local pidfile_written; |
27 | 29 |
88 | 90 |
89 -- Set signal handlers | 91 -- Set signal handlers |
90 if signal.signal then | 92 if signal.signal then |
91 signal.signal("SIGTERM", function () | 93 signal.signal("SIGTERM", function () |
92 module:log("warn", "Received SIGTERM"); | 94 module:log("warn", "Received SIGTERM"); |
93 _G.unlock_globals(); | 95 prosody.unlock_globals(); |
94 _G.prosody_shutdown("Received SIGTERM"); | 96 prosody.shutdown("Received SIGTERM"); |
95 _G.lock_globals(); | 97 prosody.lock_globals(); |
96 end); | 98 end); |
97 | 99 |
98 signal.signal("SIGHUP", function () | 100 signal.signal("SIGHUP", function () |
99 module:log("info", "Received SIGHUP"); | 101 module:log("info", "Received SIGHUP"); |
100 _G.prosody_reload_config(); | 102 prosody.reload_config(); |
101 _G.prosody_reopen_logfiles(); | 103 prosody.reopen_logfiles(); |
102 end); | 104 end); |
103 end | 105 end |