Add log on server start for what runtime will be used

This commit is contained in:
fakeshadow 2021-04-17 22:06:04 +08:00
parent 297b172644
commit c8c041cef1
1 changed files with 14 additions and 0 deletions

View File

@ -55,6 +55,20 @@ impl Server {
}) })
.collect(); .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. // start accept thread. return waker_queue and worker handles.
match Accept::start(sockets, &builder) { match Accept::start(sockets, &builder) {
Ok((waker_queue, handles)) => { Ok((waker_queue, handles)) => {