plugins/mod_posix.lua

changeset 3022
948d511f479c
parent 2925
692b3c6c5bd2
child 3029
0c7beabfed5b
equal deleted inserted replaced
3021:bf3c4195c5f8 3022:948d511f479c
52 end 52 end
53 end 53 end
54 end); 54 end);
55 55
56 -- Don't even think about it! 56 -- Don't even think about it!
57 module:add_event_hook("server-starting", function () 57 if not prosody.start_time then -- server-starting
58 local suid = module:get_option("setuid"); 58 local suid = module:get_option("setuid");
59 if not suid or suid == 0 or suid == "root" then 59 if not suid or suid == 0 or suid == "root" then
60 if pposix.getuid() == 0 and not module:get_option("run_as_root") then 60 if pposix.getuid() == 0 and not module:get_option("run_as_root") then
61 module:log("error", "Danger, Will Robinson! Prosody doesn't need to be run as root, so don't do it!"); 61 module:log("error", "Danger, Will Robinson! Prosody doesn't need to be run as root, so don't do it!");
62 module:log("error", "For more information on running Prosody as root, see http://prosody.im/doc/root"); 62 module:log("error", "For more information on running Prosody as root, see http://prosody.im/doc/root");
63 prosody.shutdown("Refusing to run as root"); 63 prosody.shutdown("Refusing to run as root");
64 end
65 end 64 end
66 end); 65 end
66 end
67 67
68 local pidfile; 68 local pidfile;
69 local pidfile_handle; 69 local pidfile_handle;
70 70
71 local function remove_pidfile() 71 local function remove_pidfile()
138 else 138 else
139 module:log("info", "Successfully daemonized to PID %d", pposix.getpid()); 139 module:log("info", "Successfully daemonized to PID %d", pposix.getpid());
140 write_pidfile(); 140 write_pidfile();
141 end 141 end
142 end 142 end
143 module:add_event_hook("server-starting", daemonize_server); 143 if not prosody.start_time then -- server-starting
144 daemonize_server();
145 end
144 else 146 else
145 -- Not going to daemonize, so write the pid of this process 147 -- Not going to daemonize, so write the pid of this process
146 write_pidfile(); 148 write_pidfile();
147 end 149 end
148 150

mercurial