Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Restart Shell Script #286

Open
oowow-core opened this issue Apr 27, 2024 · 1 comment
Open

Auto Restart Shell Script #286

oowow-core opened this issue Apr 27, 2024 · 1 comment
Labels
invalid This doesn't seem right

Comments

@oowow-core
Copy link

oowow-core commented Apr 27, 2024

./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
Copy link
Contributor

jdhirst commented May 3, 2024

@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 🙂

@jdhirst jdhirst added the invalid This doesn't seem right label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants