1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-24 16:08:34 +03:00

improve daemonize error messages to show more useful context

This commit is contained in:
Wez Furlong 2019-09-30 22:28:19 -07:00
parent 29095f8560
commit c0411197fa

View File

@ -419,10 +419,11 @@ fn run_terminal_gui(config: Arc<config::Config>, opts: &StartCommand) -> Fallibl
if opts.daemonize {
let stdout = config.daemon_options.open_stdout()?;
let stderr = config.daemon_options.open_stderr()?;
let home_dir = dirs::home_dir().ok_or_else(|| err_msg("can't find home dir"))?;
let mut daemonize = daemonize::Daemonize::new()
.stdout(stdout)
.stderr(stderr)
.working_directory(dirs::home_dir().ok_or_else(|| err_msg("can't find home dir"))?);
.working_directory(home_dir.clone());
if !running_under_wsl() {
// pid file locking is only partly function when running under
@ -432,7 +433,21 @@ fn run_terminal_gui(config: Arc<config::Config>, opts: &StartCommand) -> Fallibl
// So, we only use a pid file when not under WSL.
daemonize = daemonize.pid_file(config.daemon_options.pid_file());
}
daemonize.start()?;
if let Err(err) = daemonize.start() {
use daemonize::DaemonizeError;
match err {
DaemonizeError::OpenPidfile
| DaemonizeError::LockPidfile(_)
| DaemonizeError::ChownPidfile(_)
| DaemonizeError::WritePid => {
failure::bail!("{} {}", err, config.daemon_options.pid_file().display());
}
DaemonizeError::ChangeDirectory => {
failure::bail!("{} {}", err, home_dir.display());
}
_ => return Err(err.into()),
}
}
}
}