修复安装pm2后无法设置开机自动启动的问题
This commit is contained in:
parent
c6d3b456d9
commit
129db4fdbc
8
jsite.sh
8
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服务启用失败"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user