diff --git a/actix-server/src/server.rs b/actix-server/src/server.rs index 08036eeb..6f75316c 100644 --- a/actix-server/src/server.rs +++ b/actix-server/src/server.rs @@ -136,11 +136,9 @@ impl Server { let is_tokio = tokio::runtime::Handle::try_current().is_ok(); match (is_actix, is_tokio) { - (false, true) => info!("Tokio runtime found. Starting in existing Tokio runtime"), - (true, _) => info!("Actix runtime found. Starting in Actix runtime"), - (_, _) => info!( - "Actix/Tokio runtime not found. Starting in newt Tokio current-thread runtime" - ), + (true, _) => info!("Actix runtime found; starting in Actix runtime"), + (_, true) => info!("Tokio runtime found; starting in existing Tokio runtime"), + (_, false) => panic!("Actix or Tokio runtime not found; halting"), } for (_, name, lst) in &builder.sockets { diff --git a/actix-server/tests/test_server.rs b/actix-server/tests/test_server.rs index 89e3916a..07eb2478 100644 --- a/actix-server/tests/test_server.rs +++ b/actix-server/tests/test_server.rs @@ -485,3 +485,29 @@ async fn worker_restart() { let _ = srv.stop(false); h.join().unwrap().unwrap(); } + +#[test] +#[should_panic] +fn no_runtime() { + // test set up in a way that would prevent time out if support for runtime-less init was added + + let addr = unused_addr(); + + let srv = Server::build() + .workers(1) + .disable_signals() + .bind("test", addr, move || { + fn_service(|_| async { Ok::<_, ()>(()) }) + }) + .unwrap() + .run(); + + let rt = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + + let _ = srv.handle().stop(true); + + rt.block_on(async { srv.await }).unwrap(); +}