-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# 기존 프로세스를 shutdown 후 새 jar를 배포하기 전 기존 jar를 백업하는 용도로 쓰인다. | ||
# server.jar 파일이 있다면 server.bak.jar로 백업하고, 아니면 아무것도 하지 않는다. | ||
|
||
if [ -f server.jar ]; then | ||
sudo mv server.jar server.bak.jar | ||
echo "server.bak.jar created." | ||
exit 0 | ||
fi | ||
|
||
echo "no server.jar file found." | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# 서버가 실행중인지 확인한다. | ||
|
||
pid=$(sudo lsof -t -i :8080) | ||
|
||
if [ -z "$pid" ]; then | ||
echo "Error: server is not running." | ||
exit 1 | ||
fi | ||
|
||
echo "PID '${pid}' is running on port 8080." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# 서버의 상태를 확인하여 실행시 실패했다면 복구한다. | ||
|
||
pid=$(sudo lsof -t -i :8080) | ||
|
||
if [ -z "$pid" ]; then | ||
echo "Error: server is not running." | ||
|
||
echo | ||
echo "========= ERROR LOG ==========" | ||
cat out.log | ||
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." | ||
|
||
"${script_dir}/startup.sh" | ||
exit 1 | ||
fi | ||
|
||
echo "recovory fail: no backup jar file found" | ||
exit 2 | ||
|
||
fi | ||
|
||
echo "PID '${pid}' is running on port 8080." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# 새로운 jar 배포가 실패했을 때 백업된 기존 jar 로 다시 서버를 시작한다. | ||
|
||
script_dir=$(dirname "$0") | ||
|
||
if [ -f "server.bak.jar" ]; then | ||
sudo mv server.bak.jar server.jar | ||
echo "backup jar recovered." | ||
"${script_dir}/runner.sh" server.jar | ||
exit_code=$? | ||
|
||
if [ $exit_code -ne 0 ]; then | ||
echo "recovory fail: error occured starting backup jar." | ||
exit 1 | ||
fi | ||
|
||
exit 0 | ||
fi | ||
|
||
echo "recovory fail: no backup jar file found" | ||
exit 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# 기존 server 프로세스를 끝낸다. | ||
|
||
pid=$(sudo lsof -t -i :8080) | ||
if [ -n "$pid" ]; then | ||
kill $pid | ||
echo "${pid} closed." | ||
exit 0 | ||
fi | ||
|
||
echo "no process running on port 8080." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# server.jar 로 새로운 서버 프로세스를 실행한다. | ||
|
||
pid=$(sudo lsof -t -i :8080) | ||
|
||
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 > out.log 2>&1 & disown | ||
echo "server started at port 8080." | ||
echo "stdout & stderr directed to 'out.log'" |