mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 19:12:56 +01:00
server: panic earlier if neither runtime detected
This commit is contained in:
parent
7e7df2f931
commit
161f239f12
@ -136,11 +136,9 @@ impl Server {
|
|||||||
let is_tokio = tokio::runtime::Handle::try_current().is_ok();
|
let is_tokio = tokio::runtime::Handle::try_current().is_ok();
|
||||||
|
|
||||||
match (is_actix, is_tokio) {
|
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"),
|
||||||
(true, _) => info!("Actix runtime found. Starting in Actix runtime"),
|
(_, true) => info!("Tokio runtime found; starting in existing Tokio runtime"),
|
||||||
(_, _) => info!(
|
(_, false) => panic!("Actix or Tokio runtime not found; halting"),
|
||||||
"Actix/Tokio runtime not found. Starting in newt Tokio current-thread runtime"
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (_, name, lst) in &builder.sockets {
|
for (_, name, lst) in &builder.sockets {
|
||||||
|
@ -485,3 +485,29 @@ async fn worker_restart() {
|
|||||||
let _ = srv.stop(false);
|
let _ = srv.stop(false);
|
||||||
h.join().unwrap().unwrap();
|
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();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user