Files
pdd_AI/docs/git-deploy-centos.md
2026-06-03 16:07:23 +08:00

1.7 KiB
Raw Permalink Blame History

Git 部署到 CentOS

1. 本地首次推送

在 Windows PowerShell 中进入项目目录:

cd D:\code\pdd
git init
git branch -M main
git add .
git status
git commit -m "Initial pdd assistant"
git remote add origin https://github.com/octopuszycn-droid/pdd_AI.git
git push -u origin main

config/shops.json、config/mail.json、.env 不会被提交。真实 Token 和邮箱授权码只放服务器本地。

2. 服务器克隆

cd /opt
git clone https://github.com/octopuszycn-droid/pdd_AI.git pdd
cd /opt/pdd

3. 创建真实配置

cp config/shops.example.json config/shops.json
cp config/mail.example.json config/mail.json
vi config/shops.json
vi config/mail.json

创建 .env:

cat > /opt/pdd/.env <<'EOF'
PDD_ASSISTANT_HOST=0.0.0.0
PDD_ASSISTANT_PORT=3456
PDD_DAILY_PAUSE_TIME=07:50
PDD_CONTROL_TOKEN=replace-with-control-password
COZE_API_TOKEN=replace-with-coze-service-token
PDD_MAIL_AUTH_CODE=replace-with-mail-auth-code
EOF

chmod 600 /opt/pdd/.env

4. 启动

npm start

后台运行用 systemd:

cat > /etc/systemd/system/pdd-assistant.service <<'EOF'
[Unit]
Description=PDD Customer Service Reply Assistant
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=/opt/pdd
EnvironmentFile=/opt/pdd/.env
ExecStart=/usr/bin/node /opt/pdd/server/index.js
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now pdd-assistant

5. 后续更新

本地提交并推送:

git add .
git commit -m "Update assistant"
git push

服务器拉取并重启:

cd /opt/pdd
git pull
systemctl restart pdd-assistant