From 917d69c17160858d16eb041527433070bef1f808 Mon Sep 17 00:00:00 2001 From: milky0217 Date: Wed, 15 Jul 2026 11:05:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Graceful=20shutdown=20(10s)=EF=BC=9Bbac?= =?UTF-8?q?kup=20=E6=A0=BC=E5=BC=8F=E5=85=BC=E5=AE=B9=20.dump.gz=EF=BC=9B?= =?UTF-8?q?=E5=AE=B9=E5=99=A8=E8=BF=9E=E6=8E=A5=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common.sh | 4 ++-- src/main.rs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index 3bad4f7..2b03ff8 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -279,8 +279,8 @@ backup_database() { } cleanup_old_db_backups() { - local keep="${1:-1}" - local to_del; to_del=$(remote "ls -t ${REMOTE_DIR}/backups/${DB_NAME}_*.dump 2>/dev/null | tail -n +$((keep+1))" || echo "") + local keep="${1:-7}" + local to_del; to_del=$(remote "ls -t ${REMOTE_DIR}/backups/${DB_NAME}_*.dump* 2>/dev/null | tail -n +$((keep+1))" || echo "") [ -z "$to_del" ] && return 0 log_step "清理旧数据库备份(保留 ${keep} 个)..." echo "$to_del" | while read -r f; do [ -n "$f" ] && remote "rm -f '${f}'" 2>/dev/null && echo " 删除: $(basename "$f")" || true; done diff --git a/src/main.rs b/src/main.rs index 2bb78d6..2a00402 100644 --- a/src/main.rs +++ b/src/main.rs @@ -325,6 +325,7 @@ async fn main() -> std::io::Result<()> { create_server_config(pool_clone.clone(), http_client_clone.clone(), app_state_clone.clone()) }) .keep_alive(std::time::Duration::from_secs(30)) + .shutdown_timeout(10) .backlog(1024) .bind_openssl(&addr, ssl_builder) { @@ -348,6 +349,7 @@ async fn main() -> std::io::Result<()> { create_server_config(pool_clone.clone(), http_client_clone.clone(), app_state_clone.clone()) }) .keep_alive(std::time::Duration::from_secs(30)) + .shutdown_timeout(10) .backlog(1024) .bind(&addr) {