write server test (#19)

This commit is contained in:
Carl Lerche
2020-04-03 12:21:39 -07:00
committed by GitHub
parent e3a7aac271
commit 4ac69aeb76
5 changed files with 143 additions and 6 deletions

View File

@@ -1,6 +1,8 @@
use mini_redis::{server, DEFAULT_PORT};
use clap::Clap;
use tokio::net::TcpListener;
use tokio::signal;
#[tokio::main]
pub async fn main() -> mini_redis::Result<()> {
@@ -10,7 +12,11 @@ pub async fn main() -> mini_redis::Result<()> {
let cli = Cli::parse();
let port = cli.port.unwrap_or(DEFAULT_PORT.to_string());
server::run(&port).await
// Bind a TCP listener
let listener = TcpListener::bind(&format!("127.0.0.1:{}", port)).await?;
server::run(listener, signal::ctrl_c()).await
}
#[derive(Clap, Debug)]