MCPcopy Create free account
hub / github.com/Firstyear/opensuse-proxy-cache / do_main

Function do_main

redis-server/src/main.rs:269–315  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

267}
268
269async fn do_main() {
270 debug!("Starting");
271 let Config {
272 cache_size,
273 cache_path,
274 bind_addr,
275 durable_fs,
276 } = Config::from_args();
277
278 let addr = match net::SocketAddr::from_str(&bind_addr) {
279 Ok(a) => a,
280 Err(e) => {
281 error!(
282 "Could not parse redis server address {} -> {:?}",
283 bind_addr, e
284 );
285 return;
286 }
287 };
288
289 let (shutdown_tx, shutdown_rx) = oneshot::channel();
290
291 let mut handle = tokio::spawn(async move {
292 run_server(cache_size, cache_path, durable_fs, addr, shutdown_rx).await;
293 });
294
295 tokio::select! {
296 Some(()) = async move {
297 let sigterm = tokio::signal::unix::SignalKind::terminate();
298 tokio::signal::unix::signal(sigterm).unwrap().recv().await
299 } => {}
300 Ok(()) = tokio::signal::ctrl_c() => {
301 }
302 _ = &mut handle => {
303 warn!("Server has unexpectedly stopped!");
304 return;
305 }
306 }
307
308 info!("Starting shutdown process ...");
309 shutdown_tx
310 .send(())
311 .expect("Could not send shutdown signal!");
312 // Ignore if there is an error from the handler on return.
313 let _ = handle.await;
314 info!("Server has stopped!");
315}
316
317#[tokio::main]
318async fn main() {

Callers 1

mainFunction · 0.70

Calls 1

run_serverFunction · 0.85

Tested by

no test coverage detected