Skip to content

Commit

Permalink
update redeploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
Luphia1984 committed Oct 21, 2024
1 parent 49031da commit f1beb9a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions shell/auto_redeploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# 定義要檢查的應用程式名稱
APP_NAME="BAIFA"

# 設定工作目錄
cd /workspace/BAIFA/

Expand All @@ -16,8 +19,17 @@ if [ "$LOCAL" != "$REMOTE" ]; then
echo "Running build..."
npm run build
echo "Restarting application..."
pm2 delete BAIFA
pm2 start npm --name BAIFA -- run production
pm2 delete "$APP_NAME"
pm2 start npm --name "$APP_NAME" -- run production
else
echo "No new commits."
fi

# 檢查應用程式是否已啟動
pm2 list | grep "$APP_NAME" | grep -q "online"
if [ $? -eq 0 ]; then
echo "PM2 服務 $APP_NAME 已經在運行中。"
else
echo "PM2 服務 $APP_NAME 沒有運行,正在啟動..."
pm2 start npm --name "$APP_NAME" -- run production
fi

0 comments on commit f1beb9a

Please sign in to comment.