From 129db4fdbc9ce06100717c9e76e112b42ccad7d7 Mon Sep 17 00:00:00 2001 From: jingrow Date: Fri, 15 Aug 2025 21:00:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=89=E8=A3=85pm2?= =?UTF-8?q?=E5=90=8E=E6=97=A0=E6=B3=95=E8=AE=BE=E7=BD=AE=E5=BC=80=E6=9C=BA?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=90=AF=E5=8A=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jsite.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jsite.sh b/jsite.sh index 9fd5c0f..359acc3 100644 --- a/jsite.sh +++ b/jsite.sh @@ -709,7 +709,7 @@ install_pm2() { # 设置PM2开机自启 log_info "配置PM2开机自启..." - # 直接执行PM2 startup命令,创建systemd服务文件 + # 执行PM2 startup命令创建systemd服务 log_info "执行PM2 startup命令创建systemd服务..." su - jingrow -c " export NVM_DIR=\"\$HOME/.nvm\" @@ -717,14 +717,16 @@ install_pm2() { pm2 startup systemd -u jingrow --hp /home/jingrow " + # 等待服务文件创建完成 + sleep 2 + # 检查服务文件是否创建成功 if [ -f "/etc/systemd/system/pm2-jingrow.service" ]; then log_success "PM2 systemd服务文件创建成功" # 启用systemd服务 log_info "启用PM2 systemd服务..." - systemctl enable pm2-jingrow - if [ $? -eq 0 ]; then + if systemctl enable pm2-jingrow; then log_success "PM2 systemd服务已启用" else log_warning "PM2 systemd服务启用失败"