init: 从 /root/zikai 根目录迁入

把原本散落在 /root/zikai 的 FastAPI 服务整理到 server/ 子目录,
开启独立 git 与 venv。运行时数据(config.yaml / keys / uploads)
按 .gitignore 留在工作目录但不入仓。
This commit is contained in:
zikai
2026-06-23 16:17:31 +00:00
commit 80b96d236f
31 changed files with 1491 additions and 0 deletions

37
stop.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# 通过 pidfile 优雅停止 SFTP 与 HTTP超时则 SIGKILL。
set -uo pipefail
cd "$(dirname "$0")"
ROOT="$(pwd)"
stop_pidfile() {
local name="$1" pidfile="$2"
if [ ! -f "$pidfile" ]; then
echo "$name: 无 pidfile ($pidfile),未运行。"
return 0
fi
local pid; pid="$(cat "$pidfile" 2>/dev/null || true)"
if [ -z "$pid" ] || ! kill -0 "$pid" 2>/dev/null; then
rm -f "$pidfile"
echo "$name: 进程已退出,清理 pidfile。"
return 0
fi
echo "$name: SIGTERM -> $pid ..."
kill -TERM "$pid" 2>/dev/null || true
for _ in $(seq 1 20); do
kill -0 "$pid" 2>/dev/null || break
sleep 0.25
done
if kill -0 "$pid" 2>/dev/null; then
echo "$name: 仍在运行,发送 SIGKILL..."
kill -KILL "$pid" 2>/dev/null || true
fi
rm -f "$pidfile"
echo "$name: 已停止。"
}
# 先停 SFTP避免拆解过程中又有新文件落盘再停 HTTP。
stop_pidfile "SFTP" "$ROOT/sftp.pid"
stop_pidfile "HTTP" "$ROOT/app.pid"
echo "全部服务已停止。"