perf: improve compression reliability and deployment safety

This commit is contained in:
237899745
2026-07-25 10:29:49 +08:00
parent 06220ca921
commit 9d7668bdee
34 changed files with 1391 additions and 1042 deletions

View File

@@ -12,7 +12,6 @@ use crate::services::mail::Mailer;
use crate::state::AppState;
use sqlx::postgres::PgPoolOptions;
use tracing::Level;
#[tokio::main]
async fn main() -> Result<(), AppError> {
@@ -34,11 +33,16 @@ async fn main() -> Result<(), AppError> {
.await
.map_err(|err| AppError::new(ErrorCode::Internal, "Redis 连接失败").with_source(err))?;
let image_processing_semaphore = std::sync::Arc::new(tokio::sync::Semaphore::new(
config.image_processing_concurrency as usize,
));
let state = AppState {
config,
db,
redis,
mailer: std::sync::Arc::new(mailer),
image_processing_semaphore,
};
match state.config.role.as_str() {
@@ -52,13 +56,9 @@ async fn main() -> Result<(), AppError> {
}
fn init_tracing() {
let env_filter =
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
tracing_subscriber::EnvFilter::new("info,tower_http=info,imageforge=info")
});
let env_filter = tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
tracing_subscriber::EnvFilter::new("info,tower_http=info,imageforge=info")
});
tracing_subscriber::fmt()
.with_env_filter(env_filter)
.with_max_level(Level::INFO)
.init();
tracing_subscriber::fmt().with_env_filter(env_filter).init();
}