refactor: server runtime setup
Diff
src/server.rs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
@@ -24,13 +24,15 @@ impl Server {
pub fn run(self) -> Result {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(self.threads)
.enable_all()
.thread_name("static-web-server")
.worker_threads(self.threads)
.max_blocking_threads(self.threads)
.build()?
.block_on(async {
let r = self.start_server().await;
if r.is_err() {
panic!("Server error: {:?}", r.unwrap_err())
panic!("Server error during start up: {:?}", r.unwrap_err())
}
});
@@ -43,6 +45,9 @@ impl Server {
logger::init(&opts.log_level)?;
tracing::info!("runtime worker threads {}", self.threads);
tracing::info!("runtime max blocking threads {}", self.threads);
let ip = opts.host.parse::<IpAddr>()?;
let addr = SocketAddr::from((ip, opts.port));