diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 00b96b7..3a23af6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -47,7 +47,24 @@ jobs: host: ${{ secrets.HOST }} username: 'ubuntu' key: ${{ secrets.PRIVATE_KEY }} - script: /home/ubuntu/server/deploy.sh + script: | + cd /home/ubuntu/server + if sudo lsof -i :8080; + then + echo "Port 8080 is already in use. Killing the process..." + sudo lsof -i :8080 | awk 'NR!=1 {print $2}' | sudo xargs kill -9 + fi + + while lsof -i :8080 + do + echo "Wait for killing prior process..." + sleep 1 + done + + echo "Start Spring..." + sudo nohup java -jar -Dspring.profiles.active=prod -Duser.timezone=Asia/Seoul busan-0.0.1-SNAPSHOT.jar > nohup.out 2> nohup.err < /dev/null & + + echo "Finished!" - name: Docker build and push run: |