some changes
This commit is contained in:
+28
-4
@@ -15,6 +15,7 @@ mod cache;
|
||||
mod config;
|
||||
mod database;
|
||||
mod db;
|
||||
mod file_urls;
|
||||
mod queries;
|
||||
mod row_decode;
|
||||
mod security;
|
||||
@@ -40,6 +41,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
dotenvy::dotenv().ok();
|
||||
let cli = parse_command()?;
|
||||
init_tracing();
|
||||
print_startup_credential();
|
||||
|
||||
let config = Config::load(cli.config.as_deref())?;
|
||||
if matches!(cli.command, Command::CheckConfig) {
|
||||
@@ -53,8 +55,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
return Ok(());
|
||||
}
|
||||
info!(
|
||||
"RustPad version" = %config.asset_version,
|
||||
Copyright="@linuxiarz.pl Mateusz Gruszczyński",
|
||||
host = %config.host,
|
||||
port = config.port,
|
||||
database_kind = %database_kind_label(&config.database_url),
|
||||
@@ -65,6 +65,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
upload_max_size_bytes = config.upload_max_size_bytes,
|
||||
asset_cache_max_age_seconds = config.asset_cache_max_age_seconds,
|
||||
file_cache_max_age_seconds = config.file_cache_max_age_seconds,
|
||||
files_public_url = config.files_public_url.as_deref().unwrap_or("application origin"),
|
||||
registration_enabled = config.registration_enabled,
|
||||
account_confirmation_required = config.account_confirmation_required,
|
||||
share_confirmation_required = config.share_confirmation_required,
|
||||
@@ -73,7 +74,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
user_session_ttl_days = config.user_session_ttl_days,
|
||||
smtp_configured = config.smtp.is_some(),
|
||||
authorization_type = config.authorization_type.as_str(),
|
||||
asset_version = %config.asset_version,
|
||||
"configuration loaded"
|
||||
);
|
||||
if let Some(path) = config
|
||||
@@ -106,6 +106,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
storage,
|
||||
config.upload_max_size_bytes,
|
||||
config.file_cache_max_age_seconds,
|
||||
config.files_public_url.clone(),
|
||||
config.smtp.clone(),
|
||||
config.registration_enabled && config.ldap.is_none(),
|
||||
config.account_confirmation_required,
|
||||
@@ -152,7 +153,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let address = SocketAddr::new(config.host, config.port);
|
||||
let listener = TcpListener::bind(address).await?;
|
||||
|
||||
info!(%address, asset_version = %config.asset_version, "RustPad is running");
|
||||
info!(%address, "RustPad is running");
|
||||
axum::serve(listener, app)
|
||||
.with_graceful_shutdown(shutdown_signal())
|
||||
.await?;
|
||||
@@ -160,6 +161,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn print_startup_credential() {
|
||||
eprintln!("\n{}\n", startup_credential());
|
||||
}
|
||||
|
||||
fn startup_credential() -> String {
|
||||
format!(
|
||||
"RustPad {}\nCopyright (C) 2026 Mateusz Gruszczyński @linuxiarz.pl",
|
||||
env!("CARGO_PKG_VERSION")
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum Command {
|
||||
Run,
|
||||
@@ -265,6 +277,18 @@ async fn shutdown_signal() {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod startup_tests {
|
||||
use super::startup_credential;
|
||||
|
||||
#[test]
|
||||
fn startup_credential_contains_product_identity() {
|
||||
let credential = startup_credential();
|
||||
assert!(credential.contains(&format!("RustPad {}", env!("CARGO_PKG_VERSION"))));
|
||||
assert!(credential.contains("Mateusz Gruszczyński @linuxiarz.pl"));
|
||||
}
|
||||
}
|
||||
|
||||
async fn run_migrations(db: &Database) -> Result<(), sqlx::migrate::MigrateError> {
|
||||
let path = match db.kind() {
|
||||
DatabaseKind::Sqlite => std::path::Path::new("migrations/sqlite"),
|
||||
|
||||
Reference in New Issue
Block a user