improve launch script to actually wait for the server

This commit is contained in:
vddCore 2023-01-11 15:30:19 +01:00
parent d20454392b
commit 318665a335

View file

@ -2,6 +2,7 @@
export _JAVA_OPTIONS=
SCRIPT_DIR=$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)
FIRST_RUN=1
lsof -i:43595
@ -10,21 +11,32 @@ if [ $? -ne 1 ]; then
exit
fi
if [ -f "$SCRIPT_DIR/game/data/eco/grandexchange.db" ]; then
FIRST_RUN=0
else
echo "This is first run of the single-player release in this location."
echo "Please allow some time (30-60s) for initial data structure creation before asking for support."
sleep 3
fi
cd $SCRIPT_DIR/game
java -jar -Xmx2G -Xms2G -jar server.jar &
SERVER_PID=$!
lsof -i:43595
while [ $? -eq 1 ]; do
lsof -i:43595
echo "Still waiting for the server to start..."
sleep 2
lsof -i:43595 > /dev/null
while [ $? -eq "1" ]; do
if [ $FIRST_RUN -ne "1" ]; then
echo "Still waiting for the server to start..."
sleep 2
fi
lsof -i:43595 > /dev/null
done;
java -Xmx1G -Xms1G -jar client.jar &
CLIENT_PID=$!
sleep 2
java -Xmx1G -Xms1G -jar client.jar
wait $CLIENT_PID
kill $SERVER_PID
exit