From 7bdb1491aebd4721e8d803bcd6955cf1a7380828 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Thu, 14 Jun 2018 20:51:00 +0300 Subject: [PATCH] Disable server auto-restart --- src/bin/electrs.rs | 39 ++------------------------------------- src/config.rs | 8 -------- 2 files changed, 2 insertions(+), 45 deletions(-) diff --git a/src/bin/electrs.rs b/src/bin/electrs.rs index 00feffa..4577ff5 100644 --- a/src/bin/electrs.rs +++ b/src/bin/electrs.rs @@ -2,7 +2,6 @@ extern crate electrs; extern crate error_chain; use error_chain::ChainedError; -use std::thread; use std::time::Duration; use electrs::{app::App, @@ -46,43 +45,9 @@ fn run_server(config: &Config) -> Result<()> { Ok(()) } -struct Repeat { - do_restart: bool, - iter_count: usize, -} - -impl Repeat { - fn new(config: &Config) -> Repeat { - Repeat { - do_restart: config.restart, - iter_count: 0, - } - } -} - -impl Iterator for Repeat { - type Item = (); - - fn next(&mut self) -> Option<()> { - self.iter_count += 1; - if self.iter_count == 1 { - return Some(()); // don't sleep before 1st iteration - } - thread::sleep(Duration::from_secs(1)); - if self.do_restart { - Some(()) - } else { - None - } - } -} - fn main() { let config = Config::from_args(); - for _ in Repeat::new(&config) { - match run_server(&config) { - Ok(_) => break, - Err(e) => eprintln!("{}", e.display_chain()), - } + if let Err(e) = run_server(&config) { + eprintln!("server failed: {}", e.display_chain()); } } diff --git a/src/config.rs b/src/config.rs index 37f618a..bd806fa 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,7 +8,6 @@ use std::net::SocketAddr; pub struct Config { pub log_file: String, pub log_level: simplelog::LevelFilter, - pub restart: bool, pub network_type: Network, // bitcoind JSONRPC endpoint pub db_path: String, // RocksDB directory path pub rpc_addr: SocketAddr, // for serving Electrum clients @@ -19,7 +18,6 @@ impl Config { pub fn from_args() -> Config { let mut testnet = false; let mut verbose = false; - let mut restart = false; let mut log_file = "".to_owned(); let mut db_dir = "./db".to_owned(); { @@ -35,11 +33,6 @@ impl Config { StoreTrue, "More verbose logging to stderr", ); - parser.refer(&mut restart).add_option( - &["--restart"], - StoreTrue, - "Restart the server in case of a recoverable error", - ); parser.refer(&mut log_file).add_option( &["-l", "--log-file"], Store, @@ -63,7 +56,6 @@ impl Config { } else { simplelog::LevelFilter::Info }, - restart, network_type, db_path: match network_type { Network::Mainnet => format!("{}/mainnet", db_dir),