hide global services jank in service module

Mainly to make it easier to initialize the SERVICES global correctly in
more than one place.

Also this stuff really shouldn't live at the crate root anyway.
This commit is contained in:
Charles Hall 2024-09-24 19:48:33 -07:00
parent 1fd20cdeba
commit 032e1ca3c6
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
3 changed files with 22 additions and 20 deletions

View file

@ -47,7 +47,7 @@ use crate::{
self,
error::{Error, Result},
},
Services, SERVICES,
Services,
};
pub(crate) async fn run(args: ServeArgs) -> Result<(), error::ServeCommand> {
@ -78,11 +78,9 @@ pub(crate) async fn run(args: ServeArgs) -> Result<(), error::ServeCommand> {
.map_err(Error::DatabaseError)?,
));
// This is the first and only time we initialize the SERVICE static
*SERVICES.write().unwrap() = Some(Box::leak(Box::new(
Services::build(db, config, reload_handles)
.map_err(Error::InitializeServices)?,
)));
Services::build(db, config, reload_handles)
.map_err(Error::InitializeServices)?
.install();
services().globals.err_if_server_name_changed()?;