EvEmu-Project / evemu_Crucible

Emulator for EvE Online's Crucible expansion
https://evemu.dev
174 stars 68 forks source link

Auto Restart Shell Script #286

Open oowow-core opened 5 months ago

oowow-core commented 5 months ago

./eveadmin.sh start ./eveadmin.sh stop ./eveadmin.sh monitor

!/bin/bash

THIS_FULLPATH=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)/$(basename "${BASH_SOURCE[0]}") THIS_FOLDERPATH=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)

APATH=/home/rogical/eve/evemu_Crucible/build/dist/bin ASRV_BIN=eve-server

echo "run" >gdbcommands echo "shell echo -e \"\nCRASHLOG BEGIN\n\"" >>gdbcommands echo "info program" >>gdbcommands echo "shell echo -e \"\nBACKTRACE\n\"" >>gdbcommands echo "bt" >>gdbcommands echo "shell echo -e \"\nBACKTRACE FULL\n\"" >>gdbcommands echo "bt full" >>gdbcommands echo "shell echo -e \"\nTHREADS\n\"" >>gdbcommands echo "info threads" >>gdbcommands echo "shell echo -e \"\nTHREADS BACKTRACE\n\"" >>gdbcommands echo "thread apply all bt full" >>gdbcommands

DEBUG=false

AUTH FUNCTIONS

start() { if [ "$(screen -ls | grep $ASRV_BIN)" ]; then echo $ASRV_BIN is already running else cd $APATH screen -AmdS $ASRV_BIN $THIS_FULLPATH $ASRV_BIN echo $ASRV_BIN is alive fi }

stop() { screen -S $ASRV_BIN -X kill &>/dev/null echo $ASRV_BIN is dead }

restart() { stop start echo $ASRV_BIN restarted }

monitor() { echo press ctrl+a+d to detach from the server without shutting it down sleep 5 screen -r $ASRV_BIN }

FUNCTION SELECTION

case "$1" in $ASRV_BIN) while x=1; do ./$ASRV_BIN NOW=$(date +"%s-%d-%m-%Y") echo $NOW $ASRV_BIN stopped, restarting! | tee -a $THIS_FULLPATH.log sleep 1 done ;; "start") start ;; "restart") restart ;; "stop") stop ;; "monitor") monitor ;; *) echo Your argument is invalid echo "usage: start | stop | restart | monitor" exit 1 ;; esac

jdhirst commented 5 months ago

@oowow-core Thanks for your contribution! 🎉

I will point out however that docker is the 'official' way of running evemu and you can set restart: always in your compose file so that if it crashes it always restarts.

Therefore, such a script might be a good contender to be included in the SDK instead of the main repo as it fits with the description of the SDK: https://github.com/EvEmu-Project/evemu_SDK

As such, i would request that you please open a PR with the requested changes in the SDK repo and we can have a look at them 🙂