How to run a callback function on actix-web server start?
I have solved this by joining 2 async functions, created another async function
async fn another_func() -> Result<()> {
...
}
and have used future::join() like this
let server = HttpServer::new(move || {
let app_state = {...some state};
App::new()
.data(app_state)
.wrap(middleware::Logger::default())
.service(network_api::init_service())
})
.bind(address)?
.run();
future::join(server, another_func()).await;
Ok(()
Of course if anyone has a better answer please post it