refactor main task stack through service mgr

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-13 06:07:09 +00:00
parent b8baa1223d
commit 5be679e17b
4 changed files with 93 additions and 41 deletions

View file

@ -37,7 +37,7 @@ conduit::mod_dtor! {}
static SERVICES: RwLock<Option<&Services>> = RwLock::new(None);
pub async fn init(server: &Arc<Server>) -> Result<()> {
pub async fn start(server: &Arc<Server>) -> Result<()> {
let d = Arc::new(Database::open(server).await?);
let s = Box::new(Services::build(server.clone(), d)?);
_ = SERVICES.write().expect("write locked").insert(Box::leak(s));
@ -45,7 +45,7 @@ pub async fn init(server: &Arc<Server>) -> Result<()> {
services().start().await
}
pub async fn fini() {
pub async fn stop() {
services().stop().await;
// Deactivate services(). Any further use will panic the caller.