Refuse non-replace pidfile.
If the given pid file already exists, but --replace is not given, refuse to start the server.
This commit is contained in:
parent
ec52f0b57e
commit
97076336a6
@ -1,6 +1,7 @@
|
||||
use libc::{SIGHUP, getpid, kill, pid_t};
|
||||
use std::fs::File;
|
||||
use std::io::{ErrorKind, Read, Write};
|
||||
use std::path::Path;
|
||||
|
||||
pub fn handle_pid_file(pidfile: &str, replace: bool) -> Result<(), String> {
|
||||
if replace {
|
||||
@ -8,6 +9,10 @@ pub fn handle_pid_file(pidfile: &str, replace: bool) -> Result<(), String> {
|
||||
info!("Killing old pid {}.", oldpid);
|
||||
unsafe { kill(oldpid, SIGHUP); }
|
||||
}
|
||||
} else {
|
||||
if Path::new(pidfile).exists() {
|
||||
return Err(format!("Pid file {:?} exists.", pidfile))
|
||||
}
|
||||
}
|
||||
let pid = unsafe { getpid() };
|
||||
debug!("Should write pid {} to {}", pid, pidfile);
|
||||
|
Loading…
Reference in New Issue
Block a user