Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/defguard/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ async fn main() -> Result<(), anyhow::Error> {
dotenvy::dotenv().ok();
}
let config = DefGuardConfig::new();
SERVER_CONFIG.set(config.clone())?;
SERVER_CONFIG
.set(config.clone())
.expect("Failed to initialize server config.");

// initialize tracing with version formatter
defguard_version::tracing::init(
defguard_version::Version::parse(VERSION)?,
&config.log_level,
)?;

info!("Starting ... version v{}", VERSION);
info!("Starting ... version v{VERSION}");
debug!("Using config: {config:?}");

let pool = init_db(
Expand Down
2 changes: 1 addition & 1 deletion crates/defguard_core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl DefGuardConfig {
}

// Check if cookie domain value was provided.
// If not generate it based on URL.
// If not, generate it based on URL.
fn validate_cookie_domain(&mut self) {
if self.cookie_domain.is_none() {
self.cookie_domain = Some(
Expand Down
5 changes: 2 additions & 3 deletions crates/defguard_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![allow(clippy::result_large_err)]
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
sync::{Arc, Mutex},
sync::{Arc, Mutex, OnceLock},
};

use anyhow::anyhow;
Expand Down Expand Up @@ -63,7 +63,6 @@ use sqlx::PgPool;
use tokio::{
net::TcpListener,
sync::{
OnceCell,
broadcast::Sender,
mpsc::{UnboundedReceiver, UnboundedSender},
},
Expand Down Expand Up @@ -178,7 +177,7 @@ extern crate serde;
pub static MIGRATOR: sqlx::migrate::Migrator = sqlx::migrate!("../../migrations");

pub const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), "-", env!("VERGEN_GIT_SHA"));
pub static SERVER_CONFIG: OnceCell<DefGuardConfig> = OnceCell::const_new();
pub static SERVER_CONFIG: OnceLock<DefGuardConfig> = OnceLock::new();

pub(crate) fn server_config() -> &'static DefGuardConfig {
SERVER_CONFIG
Expand Down
1 change: 0 additions & 1 deletion defguard.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ After=network-online.target
[Service]
DynamicUser=yes
User=defguard
ExecReload=/bin/kill -HUP $MAINPID
EnvironmentFile=/etc/defguard/core.conf
ExecStart=/usr/bin/defguard
KillMode=process
Expand Down