plugins/mod_posix.lua
changeset 3340 0769cc5f34b6
parent 3029 0c7beabfed5b
child 3341 a8a3e662fea7
equal deleted inserted replaced
3339:7893055e54d1 3340:0769cc5f34b6
    93 				local other_pid = pidfile_handle:read("*a");
    93 				local other_pid = pidfile_handle:read("*a");
    94 				module:log("error", "Another Prosody instance seems to be running with PID %s, quitting", other_pid);
    94 				module:log("error", "Another Prosody instance seems to be running with PID %s, quitting", other_pid);
    95 				pidfile_handle = nil;
    95 				pidfile_handle = nil;
    96 				prosody.shutdown("Prosody already running");
    96 				prosody.shutdown("Prosody already running");
    97 			else
    97 			else
       
    98 				pidfile_handle, err = io.open(pidfile, "w+");
       
    99 				if not pidfile_handle then
       
   100 					module:log("error", "Couldn't write pidfile at %s; %s", pidfile, err);
       
   101 					prosody.shutdown("Couldn't write pidfile");
       
   102 				end
    98 				pidfile_handle:write(tostring(pposix.getpid()));
   103 				pidfile_handle:write(tostring(pposix.getpid()));
    99 				pidfile_handle:flush();
   104 				pidfile_handle:flush();
   100 			end
   105 			end
   101 		end
   106 		end
   102 	end
   107 	end