diff --git a/JWT/deploy/check_and_recover.sh b/JWT/deploy/check_and_recover.sh index 46a069a..e845c95 100755 --- a/JWT/deploy/check_and_recover.sh +++ b/JWT/deploy/check_and_recover.sh @@ -2,14 +2,32 @@ # 서버의 상태를 확인하여 실행시 실패했다면 복구한다. -script_dir=$(dirname "$0") -"${script_dir}/check.sh" -exit_code=$? +pid=$(sudo lsof -t -i :8080) + +if [ -z "$pid" ]; then + echo "Error: server is not running." -if [ $exit_code -ne 0 ]; then echo echo "========= ERROR LOG ==========" cat out.log - "${script_dir}/recover.sh" - exit 1 + echo "========== LOG END ===========" + echo + + script_dir=$(dirname "$0") + + if [ -f "server.bak.jar" ]; 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 + fi + + echo "recovory fail: no backup jar file found" + exit 2 + fi + +echo "PID '${pid}' is running on port 8080." + diff --git a/JWT/deploy/startup.sh b/JWT/deploy/startup.sh index fd791de..fe7193b 100755 --- a/JWT/deploy/startup.sh +++ b/JWT/deploy/startup.sh @@ -9,7 +9,7 @@ if [ -n "$pid" ]; then exit 1 fi -nohup java -jar $1 --spring.profiles.active=dev 2>&1 > out.log & +nohup java -jar server.jar --spring.profiles.active=dev 2>&1 > out.log & echo "server started at port 8080." echo "stdout & stderr directed to 'out.log'"