From c8c041cef11851155ed2af34bd0e16f26a9890df Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Sat, 17 Apr 2021 22:06:04 +0800 Subject: [PATCH] Add log on server start for what runtime will be used --- actix-server/src/server.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/actix-server/src/server.rs b/actix-server/src/server.rs index 3f39240e..6b9a294f 100644 --- a/actix-server/src/server.rs +++ b/actix-server/src/server.rs @@ -55,6 +55,20 @@ impl Server { }) .collect(); + // Give log information on what runtime will be used. + let is_tokio = tokio::runtime::Handle::try_current().is_ok(); + let is_actix = actix_rt::System::try_current().is_some(); + + if is_tokio && !is_actix { + info!("Tokio runtime found. Starting in existing tokio runtime"); + } else if is_actix { + info!("Actix runtime found. Starting in actix runtime"); + } else { + info!( + "Actix/Tokio runtime not found. Starting in new tokio current-thread runtime" + ); + } + // start accept thread. return waker_queue and worker handles. match Accept::start(sockets, &builder) { Ok((waker_queue, handles)) => {