chore: 增加部署状态与备份保留

This commit is contained in:
que01 committed 2026-10-13 15:14:27 +08:00
1 parent d2ca528543
commit 7f67f4d685
5 files changed
+75

No files matched your search

+5
View File
@@ -4,6 +4,11 @@ import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
if (process.argv.includes("--status")) {
const statusScript = path.join(root, "scripts/deploy/status.mjs");
const result = spawnSync(process.execPath, [statusScript], { cwd: root, stdio: "inherit" });
process.exit(result.status ?? 1);
}
const target = process.env.DEPLOY_TARGET ?? "oracle_arm";
const remoteRoot = process.env.DEPLOY_ROOT ?? "/home/ubuntu/persional-brand";
const publicBaseUrl = process.env.PUBLIC_BASE_URL ?? "https://wechat.app.que01.top";
+51
View File
@@ -0,0 +1,51 @@
import path from "node:path";
import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const target = process.env.DEPLOY_TARGET ?? "oracle_arm";
const publicBaseUrl = (process.env.PUBLIC_BASE_URL ?? "https://wechat.app.que01.top").replace(
/\/$/,
"",
);
function run(command, args) {
const result = spawnSync(command, args, { cwd: root, encoding: "utf8" });
if (result.status !== 0) throw new Error(result.stderr || command + " failed");
process.stdout.write(result.stdout);
}
run("ssh", [
target,
"bash",
"-lc",
[
'source "$HOME/.nvm/nvm.sh"',
"export DEPLOY_ROOT=/home/ubuntu/persional-brand",
'printf "current=%s\\n" "$(readlink /home/ubuntu/persional-brand/current)"',
'printf "api="; test "$(pm2 pid personal-brand-api)" != "0"; echo online',
'printf "admin="; systemctl --user is-active personal-brand-admin-static.service',
'printf "database="; docker inspect -f "{{.State.Status}}" personal-brand-postgres-1',
'printf "backups="; find /home/ubuntu/persional-brand/shared/backups -maxdepth 1 -name "*.dump" | wc -l',
].join("; "),
]);
for (const route of [
"/admin/",
"/template-preview/",
"/api/health",
"/media/seed/food-package-02.jpg",
]) {
run("curl", [
"--fail",
"--silent",
"--show-error",
"--max-time",
"10",
"-o",
"/dev/null",
"-w",
route + " %{http_code}\\n",
publicBaseUrl + route,
]);
}