summaryrefslogtreecommitdiffstats
path: root/crates/auth/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/auth/src/main.rs')
-rw-r--r--crates/auth/src/main.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/crates/auth/src/main.rs b/crates/auth/src/main.rs
index 53a18dd..3f68e2f 100644
--- a/crates/auth/src/main.rs
+++ b/crates/auth/src/main.rs
@@ -10,13 +10,17 @@ use std::net::{Ipv6Addr, SocketAddr};
use clap::Parser;
use reqwest::header::CONTENT_TYPE;
use sellershut_core::auth::{AUTH_FILE_DESCRIPTOR_SET, auth_server::AuthServer};
-use stack_up::{Configuration, Services, tracing::Tracing};
+use stack_up::{Configuration, tracing::Tracing};
use tokio::{signal, task::AbortHandle};
use tonic::service::Routes;
use tower::{make::Shared, steer::Steer};
use tracing::{info, trace};
-use crate::{error::AppError, server::grpc::interceptor::MyInterceptor, state::AppState};
+use crate::{
+ error::AppError,
+ server::grpc::interceptor::MyInterceptor,
+ state::{AppState, Services},
+};
/// auth-service
#[derive(Parser, Debug)]
@@ -50,16 +54,21 @@ async fn main() -> Result<(), AppError> {
let _tracing = Tracing::builder().build(&config.monitoring);
- let services = Services::builder()
+ let mut services = stack_up::Services::builder()
.postgres(&config.database)
.await
.inspect_err(|e| tracing::error!("database: {e}"))?
.build();
+ let postgres = services
+ .postgres
+ .take()
+ .ok_or_else(|| anyhow::anyhow!("database is not ready"))?;
+
+ let services = Services { postgres };
+
trace!("running migrations");
- sqlx::migrate!("./migrations")
- .run(&services.postgres)
- .await?;
+ sqlx::migrate!("./migrations").run(&services.postgres).await?;
let (state, deletion_task) = AppState::create(services, &config).await?;