parent
c7a592933e
commit
69e0484f8d
5 changed files with 55 additions and 3 deletions
|
|
@ -2,6 +2,7 @@ use anyhow::{Context, Result};
|
|||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Settings {
|
||||
pub port: u16,
|
||||
pub database_url: String,
|
||||
pub oidc_client_id: String,
|
||||
pub oidc_client_secret: String,
|
||||
|
|
@ -21,6 +22,10 @@ pub struct Settings {
|
|||
impl Settings {
|
||||
pub fn from_env() -> Result<Self> {
|
||||
Ok(Self {
|
||||
port: std::env::var("PORT")
|
||||
.unwrap_or_else(|_| "3000".into())
|
||||
.parse()
|
||||
.context("PORT must be a valid u16")?,
|
||||
database_url: required("DATABASE_URL")?,
|
||||
oidc_client_id: required("OIDC_CLIENT_ID")?,
|
||||
oidc_client_secret: required("OIDC_CLIENT_SECRET")?,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
http: reqwest::Client::new(),
|
||||
voice: Arc::new(VoiceHub::default()),
|
||||
};
|
||||
let port = state.settings.port;
|
||||
|
||||
let app = Router::new()
|
||||
.route("/health", get(handlers::health))
|
||||
|
|
@ -55,7 +56,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
.with_state(state)
|
||||
.layer(TraceLayer::new_for_http());
|
||||
|
||||
let addr: SocketAddr = "0.0.0.0:3000".parse()?;
|
||||
let addr = SocketAddr::from(([0, 0, 0, 0], port));
|
||||
info!(%addr, "server started");
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(addr).await?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue