[factions-banking] Updated build script to run both server and client at once properly with no options plugged in
Some checks failed
build / build (21) (push) Has been cancelled
Some checks failed
build / build (21) (push) Has been cancelled
This commit is contained in:
parent
b6b73d96e8
commit
a7f8504c2c
57
run.sh
57
run.sh
@ -13,8 +13,10 @@ LOG_LEVEL=1
|
|||||||
BUILD_PATH="build"
|
BUILD_PATH="build"
|
||||||
RUN_PATH="run"
|
RUN_PATH="run"
|
||||||
RESET_ALL=0
|
RESET_ALL=0
|
||||||
|
RUN_ALL=1
|
||||||
GRADLEW_PATH=${REPO_TOP}/gradlew
|
GRADLEW_PATH=${REPO_TOP}/gradlew
|
||||||
|
declare SERVER_PID
|
||||||
|
declare CLIENT_PID
|
||||||
|
|
||||||
# $1 is text level
|
# $1 is text level
|
||||||
# LEVELS:
|
# LEVELS:
|
||||||
@ -48,18 +50,40 @@ function help() {
|
|||||||
echo -e " -r: Reset everything. This will nuke the previous install area and re-build EVERYTHING from scratch"
|
echo -e " -r: Reset everything. This will nuke the previous install area and re-build EVERYTHING from scratch"
|
||||||
echo -e " -b <path>: Specify the build area (default is cur dir $(pwd)/build)"
|
echo -e " -b <path>: Specify the build area (default is cur dir $(pwd)/build)"
|
||||||
echo -e " -b2 <path>: Specify the run area (default is cur dir $(pwd)/run)"
|
echo -e " -b2 <path>: Specify the run area (default is cur dir $(pwd)/run)"
|
||||||
|
echo -e " -a: Run everything at once (default option if nothing specified)"
|
||||||
echo -e " -h: Bring up this help message"
|
echo -e " -h: Bring up this help message"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ExitAll() {
|
||||||
|
TermWrite 1 "Cleaning up..."
|
||||||
|
if [ ! -z $SERVER_PID ]; then
|
||||||
|
TermWrite 1 "Killing PID $SERVER_PID"
|
||||||
|
kill -9 $SERVER_PID
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z $CLIENT_PID ]; then
|
||||||
|
TermWrite 1 "Killing PID $CLIENT_PID"
|
||||||
|
kill -9 $CLIENT_PID
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Close with exit code 1 because a clean close isn't guarenteed with this
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Capture CTRL+C event into ExitAll function
|
||||||
|
trap ExitAll INT
|
||||||
|
|
||||||
while getopts ":schl:g:r:b:b2:" opt; do
|
while getopts ":schl:g:r:b:b2:" opt; do
|
||||||
case ${opt} in
|
case ${opt} in
|
||||||
s)
|
s)
|
||||||
TermWrite 2 "SERVER MODE ENABLED"
|
TermWrite 2 "SERVER MODE ENABLED"
|
||||||
SERVER_MODE=1
|
SERVER_MODE=1
|
||||||
|
RUN_ALL=0
|
||||||
;;
|
;;
|
||||||
c)
|
c)
|
||||||
TermWrite 2 "CLIENT MODE ENABLED"
|
TermWrite 2 "CLIENT MODE ENABLED"
|
||||||
CLIENT_MODE=1
|
CLIENT_MODE=1
|
||||||
|
RUN_ALL=0
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
help
|
help
|
||||||
@ -125,19 +149,40 @@ if [[ $RESET_ALL -eq 1 ]]; then
|
|||||||
TermWrite 1 "All completed!"
|
TermWrite 1 "All completed!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $SERVER_MODE -eq 1 ]]; then
|
if [[ $RUN_ALL -eq 0 ]]; then
|
||||||
|
if [[ $SERVER_MODE -eq 1 ]]; then
|
||||||
TermWrite 1 "Running ./gradlew build"
|
TermWrite 1 "Running ./gradlew build"
|
||||||
$BASH_PATH $GRADLEW_PATH build
|
$BASH_PATH $GRADLEW_PATH build
|
||||||
TermWrite 1 "Running ./gradlew runServer"
|
TermWrite 1 "Running ./gradlew runServer"
|
||||||
$BASH_PATH $GRADLEW_PATH runServer
|
$BASH_PATH $GRADLEW_PATH runServer &
|
||||||
fi
|
SERVER_PID=$!
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $CLIENT_MODE -eq 1 ]]; then
|
if [[ $CLIENT_MODE -eq 1 ]]; then
|
||||||
TermWrite 1 "Running ./gradlew build"
|
TermWrite 1 "Running ./gradlew build"
|
||||||
$BASH_PATH $GRADLEW_PATH build
|
$BASH_PATH $GRADLEW_PATH build
|
||||||
TermWrite 1 "Running ./gradlew runClient"
|
TermWrite 1 "Running ./gradlew runClient"
|
||||||
$BASH_PATH $GRADLEW_PATH runClient
|
$BASH_PATH $GRADLEW_PATH runClient
|
||||||
|
CLIENT_PID=$!
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Run everything
|
||||||
|
TermWrite 1 "Running both client and server processes..."
|
||||||
|
$BASH_PATH $GRADLEW_PATH clean
|
||||||
|
$BASH_PATH $GRADLEW_PATH build
|
||||||
|
$BASH_PATH $GRADLEW_PATH runClient &
|
||||||
|
CLIENT_PID=$!
|
||||||
|
# We do not run the server in the background so the player may run commands in the server terminal
|
||||||
|
$BASH_PATH $GRADLEW_PATH runServer
|
||||||
|
SERVER_PID=$!
|
||||||
|
|
||||||
|
TermWrite 1 "Server and client processes started"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TermWrite 1 "Finished running gradlew command with exit code $?"
|
TermWrite 1 "Finished running gradlew command with exit code $?"
|
||||||
exit 0
|
|
||||||
|
# We wait and hang here until BOTH background processes finish (or until CTRL+C event)
|
||||||
|
wait
|
||||||
|
|
||||||
|
# Clean up and leave
|
||||||
|
ExitAll
|
||||||
|
Loading…
Reference in New Issue
Block a user