thruster-rs / Thruster

A fast, middleware based, web framework written in Rust
MIT License
1.07k stars 47 forks source link

how exec code after thruster::App::start #78

Closed AlbanMinassian closed 5 years ago

AlbanMinassian commented 6 years ago

Hello

main.rs

....
fn main() {
 ...
  println!("Starting server {}://{}:{}", &protocol, &host, &port); // ok display
  thruster::App::start(app, host, port);
  println!("{}", "do some others actions after start"); // <== never display 

Thanks Ami44

AlbanMinassian commented 6 years ago

I would like add line "really start .... - date" inside file server.log and write pid (to file myapp.pid) and trigger browser refresh

trezm commented 6 years ago

After the tokio loop begins running, it blocks the current execution until all work is completed. Since this is a web service, typically it won't "complete" on its own since it's listening for incoming requests.

There was a similar question asked here: https://github.com/trezm/Thruster/issues/46

For pid, you can use this: https://doc.rust-lang.org/std/process/fn.id.html

For errors, I would encourage you to have a logging service that handles any error you might encounter in your own code.

trezm commented 5 years ago

Closing for lack of activity