fail on socket error per default
Some checks are pending
continuous-integration/drone/push Build is passing

This commit is contained in:
shimunn 2019-03-16 20:34:16 +01:00
parent 3b4f13aa44
commit 22dd07cc14
2 changed files with 7 additions and 0 deletions

View File

@ -18,6 +18,7 @@ use std::io::{BufRead, BufReader, Error, ErrorKind, Result};
use std::net::{IpAddr, SocketAddr}; use std::net::{IpAddr, SocketAddr};
use std::os::unix::net::UnixStream; use std::os::unix::net::UnixStream;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::exit;
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
use structopt::StructOpt; use structopt::StructOpt;
@ -242,6 +243,9 @@ fn main() {
Ok(state) => state, Ok(state) => state,
Err(err) => { Err(err) => {
eprintln!("Failed to read from socket: {}", err); eprintln!("Failed to read from socket: {}", err);
if !opts.ignore_socket_errors {
exit(1);
}
continue; continue;
} }
}; };

View File

@ -28,6 +28,9 @@ pub struct Opts {
)] )]
pub events: Option<PathBuf>, pub events: Option<PathBuf>,
#[structopt(short = "I", long = "ignore-socket-err", env = "WG_IGNORE_SOCKET_ERR")]
pub ignore_socket_errors: bool,
#[structopt(name = "SOCKET", parse(from_os_str), env = "WG_EVENT_SOCKET")] #[structopt(name = "SOCKET", parse(from_os_str), env = "WG_EVENT_SOCKET")]
pub socket: PathBuf, pub socket: PathBuf,
} }