Software / code / prosody
Comparison
plugins/mod_posix.lua @ 3537:7bbb19804d82
mod_posix: Updated to use the new events API.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sat, 16 Oct 2010 07:45:12 +0500 |
| parent | 3481:72d3c8029178 |
| child | 3540:bc139431830b |
comparison
equal
deleted
inserted
replaced
| 3536:fab65a4692ac | 3537:7bbb19804d82 |
|---|---|
| 28 | 28 |
| 29 local umask = module:get_option("umask") or "027"; | 29 local umask = module:get_option("umask") or "027"; |
| 30 pposix.umask(umask); | 30 pposix.umask(umask); |
| 31 | 31 |
| 32 -- Allow switching away from root, some people like strange ports. | 32 -- Allow switching away from root, some people like strange ports. |
| 33 module:add_event_hook("server-started", function () | 33 module:hook("server-started", function () |
| 34 local uid = module:get_option("setuid"); | 34 local uid = module:get_option("setuid"); |
| 35 local gid = module:get_option("setgid"); | 35 local gid = module:get_option("setgid"); |
| 36 if gid then | 36 if gid then |
| 37 local success, msg = pposix.setgid(gid); | 37 local success, msg = pposix.setgid(gid); |
| 38 if success then | 38 if success then |
| 156 else | 156 else |
| 157 -- Not going to daemonize, so write the pid of this process | 157 -- Not going to daemonize, so write the pid of this process |
| 158 write_pidfile(); | 158 write_pidfile(); |
| 159 end | 159 end |
| 160 | 160 |
| 161 module:add_event_hook("server-stopped", remove_pidfile); | 161 module:hook("server-stopped", remove_pidfile); |
| 162 | 162 |
| 163 -- Set signal handlers | 163 -- Set signal handlers |
| 164 if signal.signal then | 164 if signal.signal then |
| 165 signal.signal("SIGTERM", function () | 165 signal.signal("SIGTERM", function () |
| 166 module:log("warn", "Received SIGTERM"); | 166 module:log("warn", "Received SIGTERM"); |