Server cleanup: Retrieve args in main function, start server in start_server function
This commit is contained in:
parent
bde802562f
commit
5020406acc
10
src/main.rs
10
src/main.rs
@ -28,15 +28,19 @@ fn main() {
|
||||
return;
|
||||
};
|
||||
|
||||
let context: Arc<Mutex<Context>> = Arc::default();
|
||||
let mut pool = ThreadPool::new(4);
|
||||
|
||||
let mut args = env::args();
|
||||
args.next();
|
||||
let address = args.next().unwrap_or("127.0.0.1:8080".to_string());
|
||||
start_server(path, &address);
|
||||
}
|
||||
|
||||
fn start_server(path: PathBuf, address: &str) {
|
||||
let listener = TcpListener::bind(address).expect("Invalid bind address!");
|
||||
eprintln!("Strated server!");
|
||||
|
||||
let context: Arc<Mutex<Context>> = Arc::default();
|
||||
let mut pool = ThreadPool::new(4);
|
||||
|
||||
for stream in listener.incoming() {
|
||||
eprintln!("New connection!");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user