Skip to content

Commit

Permalink
Merge pull request #9 from TG-WinG/feature/build
Browse files Browse the repository at this point in the history
feat: 배포 스크립트에 복구 기능 추가
  • Loading branch information
wwingyou authored Mar 25, 2024
2 parents d536f81 + 14ad25b commit 644576c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
3 changes: 3 additions & 0 deletions JWT/deploy/backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sudo mv server.jar server.bak.jar
22 changes: 22 additions & 0 deletions JWT/deploy/recover.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#
# use this script when new jar file exit with unexpected error.

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
17 changes: 16 additions & 1 deletion JWT/deploy/runner.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#!/bin/bash

nohup java -jar $1 --spring.profiles.active=dev 2>&1 &
nohup java -jar $1 --spring.profiles.active=dev 2>&1 > out.log &

echo "waiting for server to startup..."
sleep 60

# after sleep, check server is still running.
pid=$(sudo lsof -t -i :8080)

if [ -z "$pid" ]; then
echo "!server startup failed!"
echo "check out.log to see what happend."
exit 1
fi

echo "${pid} is successfully running on port 8080."
exit 0
4 changes: 4 additions & 0 deletions JWT/deploy/shutdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
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."
13 changes: 13 additions & 0 deletions JWT/deploy/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
#
# startup fresh deployed jar file

script_dir=$(dirname "$0")

"${script_dir}/runner.sh" server.jar
exit_code=$?

if [ $exit_code -ne 0 ]; then
"${script_dir}/recover.sh"
exit 1
fi

0 comments on commit 644576c

Please sign in to comment.