Przeglądaj źródła

add 一键部署脚本 + systemd服务脚本

cnbugs 1 tydzień temu
rodzic
commit
fd7557539f
2 zmienionych plików z 68 dodań i 0 usunięć
  1. 21 0
      autossl.service
  2. 47 0
      deploy.sh

+ 21 - 0
autossl.service

@@ -0,0 +1,21 @@
+[Unit]
+Description=Auto-SSL 证书管理服务
+After=network.target
+Wants=network.target
+
+[Service]
+Type=simple
+User=root
+WorkingDirectory=/root/auto-ssl/backend
+Environment="PORT=9090"
+Environment="ACME_PORT=8082"
+Environment="GIN_MODE=release"
+ExecStart=/root/auto-ssl/backend/autossl
+Restart=always
+RestartSec=3
+StandardOutput=journal+console
+StandardError=journal+console
+SyslogIdentifier=autossl
+
+[Install]
+WantedBy=multi-user.target

+ 47 - 0
deploy.sh

@@ -0,0 +1,47 @@
+#!/bin/bash
+set -e
+
+echo "=== Auto-SSL 一键部署脚本 ==="
+
+# 1. 拉取最新代码
+echo "1. 拉取最新代码..."
+git pull origin 0.01
+
+# 2. 编译后端
+echo "2. 编译Go后端..."
+cd backend
+go build -o autossl .
+cd ..
+
+# 3. 编译前端
+echo "3. 编译Vue前端..."
+cd frontend
+npm install --production
+npm run build
+cd ..
+
+# 4. 部署前端到backend/dist
+echo "4. 部署前端资源..."
+rm -rf backend/dist/*
+cp -rf frontend/dist/* backend/dist/
+
+# 5. 创建systemd服务
+echo "5. 安装systemd服务..."
+sudo cp autossl.service /etc/systemd/system/
+sudo systemctl daemon-reload
+sudo systemctl enable autossl
+
+# 6. 重启服务
+echo "6. 重启服务..."
+sudo systemctl restart autossl
+
+# 7. 检查状态
+sleep 2
+echo "7. 检查服务状态..."
+if curl -s http://127.0.0.1:9090/api/stats > /dev/null; then
+    echo "✅ 部署成功!服务运行在 http://0.0.0.0:9090"
+    echo "📝 日志查看:journalctl -u autossl -f"
+else
+    echo "❌ 部署失败,请检查日志:journalctl -u autossl -n 50"
+    exit 1
+fi