My application is based around a library (Library-A) that uses actix and actix-web. I am adding a second library (Library-B) that runs an http server, also using actix-web. I use a separate thread and actix::system
for this. On a SIGINT, only the Library-B actix systems closes, leaving the Library-A running. No subsequent SIGINT closes the running actix system.
What is the correct way to gracefully close down two running actix systems?
The code for Library-B, to start a new actix system and run an http server:
thread::spawn(move || {
let sys = actix::System::new("monitor");
server::new(|| App::new()
.route("/metrics", http::Method::GET, endpoint))
.bind(format!("0.0.0.0:{}", port))
.unwrap()
.start();
sys.run();
println!("Closing monitor actix system");
// --- SIGINT gets me here... how do I shut down gracefully?
});
Is it correct for me to start a new system for an independent library? How do I shut down gracefully?