-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
c63a5be
commit 9ba9889
Showing
2 changed files
with
10 additions
and
37 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,27 +1,29 @@ | ||
# run_new_was.sh | ||
|
||
#!/bin/bash | ||
|
||
# Parse port number from 'service_url.inc' | ||
CURRENT_PORT=$(cat /home/ubuntu/service_url.inc | grep -Po '[0-9]+' | tail -1) | ||
TARGET_PORT=0 | ||
|
||
echo "> Current port of running WAS is ${CURRENT_PORT}." | ||
|
||
# Find target port to switch | ||
if [ ${CURRENT_PORT} -eq 8081 ]; then | ||
TARGET_PORT=8082 | ||
TARGET_PORT=8082 | ||
elif [ ${CURRENT_PORT} -eq 8082 ]; then | ||
TARGET_PORT=8081 | ||
TARGET_PORT=8081 | ||
else | ||
echo "> No WAS is connected to nginx" | ||
echo "> No WAS is connected to nginx" | ||
fi | ||
|
||
# query pid using the TCP protocol and using the port 'TARGET_PORT' | ||
TARGET_PID=$(lsof -Fp -i TCP:${TARGET_PORT} | grep -Po 'p[0-9]+' | grep -Po '[0-9]+') | ||
|
||
if [ ! -z ${TARGET_PID} ]; then | ||
echo "> Kill WAS running at ${TARGET_PORT}." | ||
sudo kill ${TARGET_PID} | ||
echo "> Kill WAS running at ${TARGET_PORT}." | ||
sudo kill ${TARGET_PID} | ||
fi | ||
|
||
nohup java -jar -Dserver.port=${TARGET_PORT} /home/ubuntu/playground-logging/build/libs/* > /home/ubuntu/nohup.out 2>&1 & | ||
# run jar file in background | ||
nohup java -jar -Dserver.port=${TARGET_PORT} /home/ubuntu/app/build/libs/* > /home/ubuntu/nohup.out 2>&1 & | ||
echo "> Now new WAS runs at ${TARGET_PORT}." | ||
exit 0 |