RestoreMonarchy / pterodactyl-valheim

1 stars 2 forks source link

Server log output in Pterodactyl terminal #2

Closed GraysonCAdams closed 3 years ago

GraysonCAdams commented 3 years ago

Stores server output into server.log while also outputting to the Pterodactyl terminal now (previously did not show actual server output as it was directed to /dev/null).

Also replaces "RETURN" to stop with: "stop". Stop Command has been updated in Egg instructions to be "stop".

GraysonCAdams commented 3 years ago

image

GraysonCAdams commented 3 years ago

The new start_sever.sh

Checks for user input every 0,1 seconds for the "stop" command. Each 0.1s iteration retrieves the latest 3 lines of the server log, and outputs it only if its different than the previously outputted lines.

export templdpath=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
export SteamAppId=892970

# Tip: Make a local copy of this script to avoid it being overwritten by steam.
# NOTE: Minimum password length is 5 characters & Password cant be in the server name.
# NOTE: You need to make sure the ports 2456-2458 is being forwarded to your server through your local router & firewall.

# STOP: DO NOT EDIT THIS LINE, GO TO THE "Startup" TAB AND MODIFY VARIABLES THERE
./valheim_server.x86_64 -name "${SERVER_NAME}" -port 2456 -world "${SERVER_WORLD_NAME}" -password "${SERVER_PASSWORD}" -public ${SERVER_PUBLIC} > server.log 2>&1 &
# STOP: DO NOT EDIT THIS LINE, GO TO THE "Startup" TAB AND MODIFY VARIABLES THERE

echo "Server started"
echo "Type 'stop' to stop server"

export LD_LIBRARY_PATH=$templdpath

last_line=''
while :
do
    if  [[ "$last_line" != $(tail -3 server.log | grep .) ]]
    then
        last_line=$(tail -3 server.log | grep .)
        echo "$last_line"
    fi
    read -t 0.01 user_input
    if [[ $user_input = 'stop' ]]
    then
        echo 1 > server_exit.drp
        break
    fi
done

echo "Server exit signal set"
echo "You can now close this terminal"
exit 0
lilmayu commented 3 years ago

Just used this - Works perfectly.