abstract service worker pattern; restart on panic.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-11 21:00:30 +00:00
parent 03d890cd49
commit c111d2e395
8 changed files with 233 additions and 216 deletions

View file

@ -42,10 +42,12 @@ pub async fn init(server: &Arc<Server>) -> Result<()> {
let s = Box::new(Services::build(server.clone(), d)?);
_ = SERVICES.write().expect("write locked").insert(Box::leak(s));
Ok(())
services().start().await
}
pub fn fini() {
pub async fn fini() {
services().stop().await;
// Deactivate services(). Any further use will panic the caller.
let s = SERVICES
.write()