de-global services
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
7e50db4193
commit
2f85a5c1ac
36 changed files with 327 additions and 336 deletions
|
@ -1,3 +1,5 @@
|
|||
#![recursion_limit = "192"]
|
||||
|
||||
pub(crate) mod clap;
|
||||
mod mods;
|
||||
mod restart;
|
||||
|
@ -57,17 +59,38 @@ fn main() -> Result<(), Error> {
|
|||
async fn async_main(server: &Arc<Server>) -> Result<(), Error> {
|
||||
extern crate conduit_router as router;
|
||||
|
||||
if let Err(error) = router::start(&server.server).await {
|
||||
error!("Critical error starting server: {error}");
|
||||
return Err(error);
|
||||
}
|
||||
match router::start(&server.server).await {
|
||||
Ok(services) => server.services.lock().await.insert(services),
|
||||
Err(error) => {
|
||||
error!("Critical error starting server: {error}");
|
||||
return Err(error);
|
||||
},
|
||||
};
|
||||
|
||||
if let Err(error) = router::run(&server.server).await {
|
||||
if let Err(error) = router::run(
|
||||
server
|
||||
.services
|
||||
.lock()
|
||||
.await
|
||||
.as_ref()
|
||||
.expect("services initialized"),
|
||||
)
|
||||
.await
|
||||
{
|
||||
error!("Critical error running server: {error}");
|
||||
return Err(error);
|
||||
}
|
||||
|
||||
if let Err(error) = router::stop(&server.server).await {
|
||||
if let Err(error) = router::stop(
|
||||
server
|
||||
.services
|
||||
.lock()
|
||||
.await
|
||||
.take()
|
||||
.expect("services initialied"),
|
||||
)
|
||||
.await
|
||||
{
|
||||
error!("Critical error stopping server: {error}");
|
||||
return Err(error);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduit::{config::Config, info, log::Log, utils::sys, Error, Result};
|
||||
use tokio::runtime;
|
||||
use tokio::{runtime, sync::Mutex};
|
||||
|
||||
use crate::{clap::Args, tracing::TracingFlameGuard};
|
||||
|
||||
|
@ -10,6 +10,8 @@ pub(crate) struct Server {
|
|||
/// Server runtime state; public portion
|
||||
pub(crate) server: Arc<conduit::Server>,
|
||||
|
||||
pub(crate) services: Mutex<Option<Arc<conduit_service::Services>>>,
|
||||
|
||||
_tracing_flame_guard: TracingFlameGuard,
|
||||
|
||||
#[cfg(feature = "sentry_telemetry")]
|
||||
|
@ -54,6 +56,8 @@ impl Server {
|
|||
},
|
||||
)),
|
||||
|
||||
services: None.into(),
|
||||
|
||||
_tracing_flame_guard: tracing_flame_guard,
|
||||
|
||||
#[cfg(feature = "sentry_telemetry")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue