添加升级脚本
This commit is contained in:
11
README.md
11
README.md
@@ -35,6 +35,17 @@ VERSION=v0.1.0 curl -sSL https://git.littlediary.cn/CN-JS-HuiBai/PromdataPanel/r
|
||||
3. 安装依赖:`npm install --production`
|
||||
4. 启动服务:`npm start`
|
||||
|
||||
### 方式三:更新现有版本
|
||||
|
||||
如果您已经安装了本系统,可以使用随附的 `update.sh` 脚本一键升级到最新代码:
|
||||
|
||||
```bash
|
||||
# 进入程序目录
|
||||
cd /opt/promdata-panel
|
||||
# 执行更新脚本
|
||||
chmod +x update.sh && ./update.sh
|
||||
```
|
||||
|
||||
#### 3. 系统初始化
|
||||
首次运行后,访问 `http://your-ip:3000/init.html`,按照引导完成 MySQL 数据库和 Valkey 缓存的连接。
|
||||
|
||||
|
||||
52
update.sh
Normal file
52
update.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Update Script for PromdataPanel
|
||||
# -------------------------------
|
||||
|
||||
set -e
|
||||
|
||||
# Config
|
||||
APP_DIR="/opt/promdata-panel"
|
||||
SERVICE_NAME="promdatapanel"
|
||||
|
||||
# 1. Colors for logs
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}=== Starting PromdataPanel Update ===${NC}"
|
||||
|
||||
# Detect if we're in the app directory
|
||||
if [ ! -d ".git" ]; then
|
||||
if [ -d "$APP_DIR/.git" ]; then
|
||||
cd "$APP_DIR"
|
||||
else
|
||||
echo -e "${RED}Error: Not in a git repository or $APP_DIR. Please run this from the app root.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# 2. Pull latest code from current branch
|
||||
echo -e "${BLUE}Pulling latest code from git...${NC}"
|
||||
git pull
|
||||
|
||||
# 3. Update dependencies
|
||||
echo -e "${BLUE}Updating npm dependencies...${NC}"
|
||||
npm install --production
|
||||
|
||||
# 4. Restart service
|
||||
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||
echo -e "${BLUE}Restarting systemd service: $SERVICE_NAME...${NC}"
|
||||
sudo systemctl restart "$SERVICE_NAME"
|
||||
echo -e "${GREEN}Update completed and service restarted!${NC}"
|
||||
elif command -v pm2 &> /dev/null && pm2 list | grep -q "$SERVICE_NAME"; then
|
||||
echo -e "${BLUE}Restarting with PM2...${NC}"
|
||||
pm2 restart "$SERVICE_NAME"
|
||||
echo -e "${GREEN}Update completed and PM2 restarted!${NC}"
|
||||
else
|
||||
echo -e "${RED}Warning: Could not detect an active systemd service or PM2 process named '$SERVICE_NAME'.${NC}"
|
||||
echo -e "${RED}Please restart the application manually.${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}=== Update successfully finished ===${NC}"
|
||||
Reference in New Issue
Block a user