forked from jmug/stoatchat
chore: split sentry dsn into separate options per-app
This commit is contained in:
@@ -15,7 +15,7 @@ mod websocket;
|
|||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// Configure requirements for Bonfire.
|
// Configure requirements for Bonfire.
|
||||||
revolt_config::configure!();
|
revolt_config::configure!(events);
|
||||||
database::connect().await;
|
database::connect().await;
|
||||||
|
|
||||||
// Clean up the current region information.
|
// Clean up the current region information.
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
sentry_dsn = ""
|
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
mongodb = "mongodb://database"
|
mongodb = "mongodb://database"
|
||||||
redis = "redis://redis/"
|
redis = "redis://redis/"
|
||||||
@@ -14,7 +12,6 @@ voso_legacy = ""
|
|||||||
voso_legacy_ws = ""
|
voso_legacy_ws = ""
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
staging = false
|
|
||||||
|
|
||||||
[api.registration]
|
[api.registration]
|
||||||
invite_only = false
|
invite_only = false
|
||||||
@@ -68,3 +65,7 @@ background_size = 6000000
|
|||||||
icon_size = 2500000
|
icon_size = 2500000
|
||||||
banner_size = 6000000
|
banner_size = 6000000
|
||||||
emoji_size = 500000
|
emoji_size = 500000
|
||||||
|
|
||||||
|
[sentry]
|
||||||
|
api = ""
|
||||||
|
events = ""
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ pub struct ApiWorkers {
|
|||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Api {
|
pub struct Api {
|
||||||
pub staging: bool,
|
|
||||||
pub registration: ApiRegistration,
|
pub registration: ApiRegistration,
|
||||||
pub smtp: ApiSmtp,
|
pub smtp: ApiSmtp,
|
||||||
pub vapid: ApiVapid,
|
pub vapid: ApiVapid,
|
||||||
@@ -141,13 +140,19 @@ pub struct Features {
|
|||||||
pub webhooks_enabled: bool,
|
pub webhooks_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
pub struct Sentry {
|
||||||
|
pub api: String,
|
||||||
|
pub events: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
pub database: Database,
|
pub database: Database,
|
||||||
pub hosts: Hosts,
|
pub hosts: Hosts,
|
||||||
pub api: Api,
|
pub api: Api,
|
||||||
pub features: Features,
|
pub features: Features,
|
||||||
pub sentry_dsn: String,
|
pub sentry: Sentry,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
@@ -191,7 +196,7 @@ pub async fn config() -> Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Configure logging and common Rust variables
|
/// Configure logging and common Rust variables
|
||||||
pub async fn setup_logging(release: &'static str) -> Option<sentry::ClientInitGuard> {
|
pub async fn setup_logging(release: &'static str, dsn: String) -> Option<sentry::ClientInitGuard> {
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
|
|
||||||
if std::env::var("RUST_LOG").is_err() {
|
if std::env::var("RUST_LOG").is_err() {
|
||||||
@@ -205,12 +210,11 @@ pub async fn setup_logging(release: &'static str) -> Option<sentry::ClientInitGu
|
|||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
log::info!("Starting {release}");
|
log::info!("Starting {release}");
|
||||||
|
|
||||||
let config = config().await;
|
if dsn.is_empty() {
|
||||||
if config.sentry_dsn.is_empty() {
|
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(sentry::init((
|
Some(sentry::init((
|
||||||
config.sentry_dsn,
|
dsn,
|
||||||
sentry::ClientOptions {
|
sentry::ClientOptions {
|
||||||
release: Some(release.into()),
|
release: Some(release.into()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -221,12 +225,12 @@ pub async fn setup_logging(release: &'static str) -> Option<sentry::ClientInitGu
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! configure {
|
macro_rules! configure {
|
||||||
() => {
|
($application: ident) => {
|
||||||
let _sentry = $crate::setup_logging(concat!(
|
let config = $crate::config().await;
|
||||||
env!("CARGO_PKG_NAME"),
|
let _sentry = $crate::setup_logging(
|
||||||
"@",
|
concat!(env!("CARGO_PKG_NAME"), "@", env!("CARGO_PKG_VERSION")),
|
||||||
env!("CARGO_PKG_VERSION")
|
config.sentry.$application,
|
||||||
))
|
)
|
||||||
.await;
|
.await;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ pub async fn authifier_config() -> AuthifierConfig {
|
|||||||
#[launch]
|
#[launch]
|
||||||
async fn rocket() -> _ {
|
async fn rocket() -> _ {
|
||||||
// Configure logging and environment
|
// Configure logging and environment
|
||||||
revolt_config::configure!();
|
revolt_config::configure!(api);
|
||||||
|
|
||||||
// Start web server
|
// Start web server
|
||||||
web().await
|
web().await
|
||||||
|
|||||||
Reference in New Issue
Block a user