Shut down server when quitting

This commit is contained in:
Antoine Gersant 2016-09-21 23:44:41 -07:00
parent f82ddc484c
commit e631138562

View file

@ -37,8 +37,7 @@ mod vfs;
fn main() { fn main() {
println!("Spawning server thread"); println!("Starting up server");
std::thread::spawn(move || {
let mut api_chain; let mut api_chain;
{ {
let api_handler; let api_handler;
@ -59,8 +58,10 @@ fn main() {
let mut mount = Mount::new(); let mut mount = Mount::new();
mount.mount("/api/", api_chain); mount.mount("/api/", api_chain);
mount.mount("/", Static::new(Path::new("web"))); mount.mount("/", Static::new(Path::new("web")));
Iron::new(mount).http("localhost:3000").unwrap(); let mut server = Iron::new(mount).http("localhost:3000").unwrap();
});
ui::run(); ui::run();
println!("Shutting down server");
server.close().unwrap();
} }