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

[BUGFIX] Auto restart botty after crashing #14

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Resources/Privat/Scripts/botty.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh

######################################################
#
# T3Bot
#
# @author Simon Gilli <[email protected]>
#
# @link http://www.t3bot.de
# @link http://wiki.typo3.org/T3Bot
#
# @param NAME
# @param PID file
# @param LOG file
# @param DAEMON file
# @param DAEMON options
#
######################################################


# Read arguments and shift to get access to all options
NAME=$1
PIDFILE=$2
LOGFILE=$3
DAEMON=$4

shift 4

# Test arguments
test -n $NAME || exit 0
test -f $PIDFILE || exit 0
test -x $DAEMON || exit 0
test -n $@ || exit 0

# Loop while PID file exists
while [ -f $PIDFILE ]
do
"$DAEMON" $@
echo "$NAME restored" >> $LOGFILE
done

echo "$NAME has terminated" >> $LOGFILE

exit 0
4 changes: 3 additions & 1 deletion Resources/Privat/Scripts/daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ LOGFILE="/var/log/${NAME}.log"
# CHANGE this to your PHP path
DAEMON="/usr/bin/php"
# CHANGE this to your bot path
DAEMON_HELPER="/var/www/t3bot.de/botty.sh"
DAEMON_OPTS="/var/www/t3bot.de/botty.php"

START_OPTS="--start --background --make-pidfile --pidfile ${PIDFILE} --exec ${DAEMON} ${DAEMON_OPTS}"
START_OPTS="--start --background --make-pidfile --pidfile ${PIDFILE} --exec ${DAEMON_HELPER} ${NAME} ${PIDFILE} ${DAEMON} ${DAEMON_OPTS}"
STOP_OPTS="--stop --pidfile ${PIDFILE}"

test -x $DAEMON || exit 0
test -x $DAEMON_HELPER || exit 0

set -e

Expand Down