Add error messages when failed to start server
This commit is contained in:
@ -198,7 +198,7 @@ fn verify_config(config: ParsedConfig) -> Result<ParsedConfig, ConfigError> {
|
||||
}
|
||||
|
||||
for key in &upstream_names {
|
||||
if !used_upstreams.contains(key) {
|
||||
if !used_upstreams.contains(key) && !key.eq("echo") && !key.eq("ban") {
|
||||
warn!("Upstream {} not used", key);
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,12 @@ mod servers;
|
||||
use crate::config::Config;
|
||||
use crate::servers::Server;
|
||||
|
||||
use std::env;
|
||||
use log::{debug, error};
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let config_path = env::var("FOURTH_CONFIG").unwrap_or_else(|_| "/etc/fourth/config.yaml".to_string());
|
||||
let config_path =
|
||||
env::var("FOURTH_CONFIG").unwrap_or_else(|_| "/etc/fourth/config.yaml".to_string());
|
||||
|
||||
let config = match Config::new(&config_path) {
|
||||
Ok(config) => config,
|
||||
@ -23,6 +24,6 @@ fn main() {
|
||||
let mut server = Server::new(config.base);
|
||||
debug!("{:?}", server);
|
||||
|
||||
let res = server.run();
|
||||
error!("Server returned an error: {:?}", res);
|
||||
let _ = server.run();
|
||||
error!("Server ended with errors");
|
||||
}
|
||||
|
@ -83,10 +83,16 @@ impl Server {
|
||||
let handle = tokio::spawn(async move {
|
||||
match config.protocol.as_ref() {
|
||||
"tcp" => {
|
||||
let _ = tcp::proxy(config).await;
|
||||
let res = tcp::proxy(config.clone()).await;
|
||||
if res.is_err() {
|
||||
error!("Failed to start {}: {}", config.name, res.err().unwrap());
|
||||
}
|
||||
}
|
||||
"kcp" => {
|
||||
let _ = kcp::proxy(config).await;
|
||||
let res = kcp::proxy(config.clone()).await;
|
||||
if res.is_err() {
|
||||
error!("Failed to start {}: {}", config.name, res.err().unwrap());
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
error!("Invalid protocol: {}", config.protocol)
|
||||
|
Reference in New Issue
Block a user