diff --git a/.github/workflows/auto-deployment.yml b/.github/workflows/auto-deployment.yml index 25caeca..01c8a92 100644 --- a/.github/workflows/auto-deployment.yml +++ b/.github/workflows/auto-deployment.yml @@ -60,10 +60,10 @@ jobs: scp -i private_key.pem $jarPath "${username}@${host}:~/server.jar" - name: Startup new uploaded jar - run: ssh -i private_key.pem "${username}@${host}" "deploy/startup.sh" + run: ssh -i private_key.pem "${username}@${host}" "source ~/.profile; deploy/startup.sh" - name: Wait 30 seconds for server to startup run: sleep 30 - name: Check and Recover - run: ssh -i private_key.pem "${username}@${host}" "deploy/check_and_recover.sh" + run: ssh -i private_key.pem "${username}@${host}" "source ~/.profile; deploy/check_and_recover.sh" diff --git a/JWT/deploy/check_and_recover.sh b/JWT/deploy/check_and_recover.sh index e845c95..2b7477c 100755 --- a/JWT/deploy/check_and_recover.sh +++ b/JWT/deploy/check_and_recover.sh @@ -19,9 +19,8 @@ if [ -z "$pid" ]; then sudo mv server.bak.jar server.jar echo "backup jar recovered." - nohup java -jar server.jar --spring.profiles.active=dev 2>&1 > out.log & - echo "backup server no running on port 8080" - exit 0 + "${script_dir}/startup.sh" + exit 1 fi echo "recovory fail: no backup jar file found" diff --git a/JWT/deploy/startup.sh b/JWT/deploy/startup.sh index fe7193b..b7df3ad 100755 --- a/JWT/deploy/startup.sh +++ b/JWT/deploy/startup.sh @@ -8,8 +8,6 @@ if [ -n "$pid" ]; then echo "Error: PID '${pid}' is conneted to port 8080. cannot startup new process." exit 1 fi - -nohup java -jar server.jar --spring.profiles.active=dev 2>&1 > out.log & +nohup java -jar server.jar --spring.profiles.active=dev > out.log 2>&1 & disown echo "server started at port 8080." echo "stdout & stderr directed to 'out.log'" -