# Git 部署到 CentOS ## 1. 本地首次推送 在 Windows PowerShell 中进入项目目录: ```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. 服务器克隆 ```bash cd /opt git clone https://github.com/octopuszycn-droid/pdd_AI.git pdd cd /opt/pdd ``` ## 3. 创建真实配置 ```bash 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`: ```bash 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. 启动 ```bash npm start ``` 后台运行用 systemd: ```bash 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. 后续更新 本地提交并推送: ```powershell git add . git commit -m "Update assistant" git push ``` 服务器拉取并重启: ```bash cd /opt/pdd git pull systemctl restart pdd-assistant ```