In our support boards we aim to provide support for the B3 core in its current state. Older releases of B3 are NOT supported. Check our front page for the latest version. You may post feature requests in our General Discussion board. Modifications and Hacks of the core B3 code are NOT supported.
Before you ask for support: [ Read the Support Instructions ] - More info: [ Full Support Disclaimer ]

You are here: Big Brother Bot ForumSupport ForumsGeneral Usage Support (Moderator: MordyT)B3 is crashing regularly, please help.
Pages: [1]   Go Down
  Print  
Author Topic: B3 is crashing regularly, please help.  (Read 2447 times) Bookmark and Share
Jr. Member
**
Posts: 30
Offline Offline
« on: May 15, 2009, 10:49:56 AM »

I apologize for re-posting, but I am in a real bind here. I have b3 running remotely using bakes' ftptail method and b3 somehow stops processing the log file after a while of running. I have to restart 3-5 times a day. The b3 log will keep putting out messages that it is querying and sending commands through rcon, but it appears to just lose it's grip on the log that is syncing through ftptail. I have dove into the code a bit since I am kinda familiar with python, but I don't have enough time to learn my way around the codebase enough to pinpoint the problem. I would be very grateful if somebody could explain to me how and where b3 gets updates from the log. I would like to write a patch that does something like the following pseudo-code every minute or so. I could do it fairly easily using multircon and a cron job, but I would really like to keep it within b3.

restart b3 if current time - last log update > 1 minute and number of players on server > 0

So it would need to hook into the parser someplace and update a global variable every time a line is read from the log (maybe have a config setting in b3.xml to control whether this happens or not) and the above pseudo-code would need to get placed in the scheduler to run every specified interval.

Again, any help would be appreciated. I am getting really desperate at this point for a solution to get this working correctly as we have enjoyed the benefits of b3 for too long to go without it. I would love the opportunity to learn the codebase a bit better so that I can contribute more, but at this point, first order of business has to be getting b3 stabilized on my servers.
Logged

Senior Dev.
*
OS: Linux
Type: Home user
Posts: 3483
Offline Offline
WWW
Support Specialty: B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
« Reply #1 on: May 15, 2009, 11:17:39 AM »

Hi, I don't quite understand what you are trying to achieve. Anyway the starting point is the Parser class which reads the log. Hope that helps a bit
Logged

Jr. Member
**
Posts: 30
Offline Offline
« Reply #2 on: May 15, 2009, 11:22:39 AM »

Well, I would like to figure out why b3 stops reading the log and correct that problem.

If I can't do that, I would like to detect when b3 stops reading the log and force a restart.

Thanks for replying.
Logged
Senior Dev.
*
OS: Linux
Type: Home user
Posts: 3483
Offline Offline
WWW
Support Specialty: B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
« Reply #3 on: May 15, 2009, 12:13:48 PM »

I think if the log file is missing for a bref instant (as it occurs when you are using a tool to rotate le log like logrotate) B3 gets confused and stops parsing the log.
Logged

Jr. Member
**
Posts: 30
Offline Offline
« Reply #4 on: May 15, 2009, 12:20:52 PM »

I'll bet this happens when ftptail dies and restarts...

Maybe I will send a restart signal to b3 in my ftptail restart script.

Thanks
Logged
Jr. Member
**
Posts: 30
Offline Offline
« Reply #5 on: May 15, 2009, 12:53:27 PM »

Another question then:

I noticed in the run_autorestart function in run.py that it has a method for handling different return statuses. Any idea how I would go about getting b3 to close with status 221 (for restart) from bash? I tried sending various signals with kill, but it didn't do what I expected.
Logged
Senior Dev.
*
OS: Linux
Type: Home user
Posts: 3483
Offline Offline
WWW
Support Specialty: B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
« Reply #6 on: May 15, 2009, 02:48:10 PM »

the !restart command (that sends the signal) is buggy, there is a patch : http://www.bigbrotherbot.com/forums/index.php?topic=871.0
Logged

Jr. Member
**
Posts: 30
Offline Offline
« Reply #7 on: May 15, 2009, 06:26:06 PM »

the !restart command (that sends the signal) is buggy, there is a patch : http://www.bigbrotherbot.com/forums/index.php?topic=871.0

That's from in game though. If there is a way to send b3 commands from the linux command line, that would be perfect (it would also be a great help to my web rcon project). If not, I need to figure out some kind of way to restart b3 gracefully from outside of it.
Logged
Jr. Member
**
Posts: 30
Offline Offline
« Reply #8 on: May 15, 2009, 06:41:16 PM »

From reading back through the remote b3 thread, it looks like bakes had this problem and fixed it. I asked him a couple days ago for his workaround but he never replied. I even added him to xfire and can't seem to get a hold of him.
Logged
B3 Contrib/Support
*
OS: --No B3 installed--
Type: --No B3 installed--
Posts: 1225
Offline Offline
Support Specialty: B3-Core, CoD/BFBC2 parsers, FTP-functionality, Plugin development
« Reply #9 on: May 15, 2009, 10:32:44 PM »

Sorry, here I am!

A couple of my scripts:

B3 Restarter
Code:
#!/bin/bash

########### SETTINGS  ############

## the user that must be used to run the bot
USER=melvyn

## the big brother bot main config file
B3_CONFIGFILE="/home/melvyn/james/b3source/ff/b3/conf/b3-obj.xml"

## where b3_run_obj.py is located
B3_BIN="/home/melvyn/james/b3source/ff/b3_run_obj.py"

## where the python binary is located
PYTHON_BIN=/usr/bin/python

########### SETTINGS END ############

set -e
DEBUG=off
B3_OPTS="--config $B3_CONFIGFILE"
B3_PID_FILE="${HOME}/.b3-$(echo $B3_CONFIGFILE | tr '/' '_').pid"

if [ ! -f "$B3_CONFIGFILE" ]; then
  echo "ERROR: config file not found ($B3_CONFIGFILE)"
  exit 1
fi


if [ ! -f "$B3_BIN" ]; then
  echo "ERROR: file not found : '$B3_BIN'"
  exit 1
fi
if [ ! -x "$B3_BIN" ]; then
  echo "ERROR: cannot execute '$B3_BIN'"
  exit 1
fi
if [ ! -f "$PYTHON_BIN" ]; then
  echo "ERROR: file not found : '$PYTHON_BIN'"
  exit 1
fi
if [ ! -x "$PYTHON_BIN" ]; then
  echo "ERROR: cannot execute '$PYTHON_BIN'"
  exit 1
fi

if [ "$(whoami)" != "$USER" ]; then
echo "ERROR: you have to run that script as $USER"
exit 1
fi


function debug() {
if [ "$DEBUG" = "on" ]; then
echo DEBUG: $@
fi
}


function do_start {
cd $(dirname $B3_BIN)
$PYTHON_BIN $B3_BIN $B3_OPTS &
echo $! > $B3_PID_FILE
}

function do_stop {
NB_PROCESS=`ps ax | grep b3_run_obj | grep "$B3_CONFIGFILE" | grep -v grep | wc -l`
if [ $NB_PROCESS -gt 1 ]; then
echo "ERROR: multiple b3 processes found, you'd better kill thoses processes by hand."
elif [ $NB_PROCESS -eq 1 ]; then
if [ -f $B3_PID_FILE ]; then
PID=$(cat $B3_PID_FILE)
NB_PROCESS=`ps hax $PID | grep b3_run_obj | grep "$B3_CONFIGFILE" | grep -v grep | wc -l`
if [ $NB_PROCESS -eq 1 ]; then
kill -15 $PID
else
echo "ERROR: process N° $PID does not seem to be b3"
echo "kill b3 by hand"
fi
fi
else
echo "WARNING: are you sure b3 is running ?"
fi
}


kill_programme() {
        PID=`ps hax | grep "b3_run_obj" | grep "$B3_CONFIGFILE" | grep -v grep | cut -d' ' -f1 | head -n1`
        echo "killing process [$PID]"
        kill -9 $PID
}


case "$1" in
  start)
echo "Starting Big Brother Bot"
NB_PROCESS=`ps ax | grep b3_run_obj | grep "$B3_CONFIGFILE" | grep -v grep | wc -l`
if [ $NB_PROCESS -eq 0 ]; then
do_start
else
echo "ERROR: b3 is already running"
fi
;;
  stop)
echo -n "Stopping Big Brother Bot"
do_stop
echo "."
;;

  restart)
        echo -n "Restarting Big Brother Bot"
do_stop
sleep 1
do_start
;;

status)
debug "status:"
NB_PROCESS=`ps ax | grep b3_run_obj | grep "$B3_CONFIGFILE" | grep -v grep | wc -l`
debug "NB_PROCESS: $NB_PROCESS"
if [ $NB_PROCESS -gt 1 ]; then
echo "WARNING: multiple b3 processes found !"
elif [ $NB_PROCESS -eq 1 ]; then
echo "running :)"
else
echo "not running :("
fi
;;

kill)
kill_programme
;;
  *)
PROG_NAME=`basename $0`
echo "Usage: $PROG_NAME {start|stop|restart|status}"
exit 1
esac

exit 0



FTPTail Downloader
Code:
#!/bin/bash

########### SETTINGS  ############

## the user that must be used to run the bot
USER=melvyn

FTPTAIL_OPT=" -s 1 -f -p passwd -n 400"
FTPTAIL_SOURCE="731439@8.12.22.225/codww/main/games_mp.log"
##Ftptail name. Must be named individually for each instance of ftptail that is running.


## where b3_run.py is located
FTPTAIL_BIN="/home/melvyn/james/b3source/ff/b3/gamelog/ftptail-obj.pl"
FTPTAIL_DEST="/home/melvyn/james/b3source/ff/b3/gamelog/games_mp_obj.log"
## where the python binary is located
PERL_BIN=/usr/bin/perl

########### SETTINGS END ############

set -e
DEBUG=off
FTPTAIL_PID_FILE="${HOME}/.ftptail-$(echo $FTPTAIL_SOURCE | tr '/' '_').pid"


if [ ! -f "$FTPTAIL_BIN" ]; then
  echo "ERROR: file not found : '$FTPTAIL_BIN'"
  exit 1
fi
if [ ! -x "$FTPTAIL_BIN" ]; then
  echo "ERROR: cannot execute '$FTPTAIL_BIN'"
  exit 1
fi
if [ ! -f "$PERL_BIN" ]; then
  echo "ERROR: file not found : '$PERL_BIN'"
  exit 1
fi
if [ ! -x "$PERL_BIN" ]; then
  echo "ERROR: cannot execute '$PERL_BIN'"
  exit 1
fi

if [ "$(whoami)" != "$USER" ]; then
echo "ERROR: you have to run that script as $USER"
exit 1
fi


function debug() {
if [ "$DEBUG" = "on" ]; then
echo DEBUG: $@
fi
}


function do_start {
$PERL_BIN $FTPTAIL_BIN $FTPTAIL_OPT $FTPTAIL_SOURCE > $FTPTAIL_DEST 2>> /dev/null &
echo $! > $FTPTAIL_PID_FILE
}

function do_stop {
NB_PROCESS=`ps ax | grep $(basename $FTPTAIL_BIN) | grep "$FTPTAIL_SOURCE" | grep -v grep | wc -l`
if [ $NB_PROCESS -gt 1 ]; then
echo "ERROR: multiple processes found, you'd better kill thoses processes by hand."
elif [ $NB_PROCESS -eq 1 ]; then
if [ -f $FTPTAIL_PID_FILE ]; then
PID=$(cat $FTPTAIL_PID_FILE)
NB_PROCESS=`ps hax $PID | grep $(basename $FTPTAIL_BIN) | grep "$FTPTAIL_SOURCE" | grep -v grep | wc -l`
if [ $NB_PROCESS -eq 1 ]; then
kill -15 $PID
else
echo "ERROR: process N° $PID does not seem to be ftptail"
echo "kill ftptail by hand"
fi
fi
else
echo "WARNING: are you sure ftptail is running ?"
fi
}


kill_programme() {
        PID=`ps hax | grep $(basename $FTPTAIL_BIN) | grep "$FTPTAIL_SOURCE" | grep -v grep | cut -d' ' -f1 | head -n1`
        echo "killing process [$PID]"
        kill -9 $PID
}


case "$1" in
  start)
echo "Starting ftptail"
NB_PROCESS=`ps ax | grep $(basename $FTPTAIL_BIN) | grep "$FTPTAIL_SOURCE" | grep -v grep | wc -l`
if [ $NB_PROCESS -eq 0 ]; then
do_start
else
echo "ERROR: ftptail is already running"
fi
;;
  stop)
echo -n "Stopping ftptail"
do_stop
echo "."
;;

  restart)
echo -n "Restarting ftptail"
do_stop
sleep 1
do_start
;;

status)
debug "status:"
NB_PROCESS=`ps ax | grep $(basename $FTPTAIL_BIN) | grep "$B3_CONFIGFILE" | grep -v grep | wc -l`
debug "NB_PROCESS: $NB_PROCESS"
if [ $NB_PROCESS -gt 1 ]; then
echo "WARNING: multiple processes found !"
      exit 2
elif [ $NB_PROCESS -eq 1 ]; then
echo "running :)"
      exit 0
else
echo "not running :("
      exit 1
fi
;;

kill)
kill_programme
;;
  *)
PROG_NAME=`basename $0`
echo "Usage: $PROG_NAME {start|stop|restart|status}"
exit 1
esac

exit 0



Game Starter
Code:
#!/bin/ksh
echo "Starting FTPTail"
echo ""
cd /home/melvyn/james/b3source/ff/b3/gamelog
./ftptail-obj.sh restart
sleep 5
echo "Starting B3Bot"
echo ""
cd /home/melvyn/b3starters
./bigbrotherbot restart
while true
do
echo "Checksum test for logfile 1"
chksum1=`md5sum /home/melvyn/james/b3source/ff/b3/gamelog/games_mp_obj.log`
echo "MD5Sum for logfile 1 = $chksum1"
sleep 60
echo "Checksum test for logfile 2"
chksum2=`md5sum /home/melvyn/james/b3source/ff/b3/gamelog/games_mp_obj.log`
echo "MD5Sum for logfile 2 = $chksum2"
if [ "$chksum1" = "$chksum2" ]
then
echo "Logfiles are identical, restarting bot"
cd /home/melvyn/james/b3source/ff/b3/gamelog
./ftptail-obj.sh restart
sleep 10
cd /home/melvyn/b3starters
./bigbrotherbot restart
fi
done

It's not a fix, as such, since it doesn't fix the problem. What it does do, is check if either of the logfiles have the same checksum, if either of them are, it restarts the bot and ftptail.
« Last Edit: May 17, 2009, 12:43:46 AM by xlr8or » Logged

Jr. Member
**
Posts: 30
Offline Offline
« Reply #10 on: May 16, 2009, 07:38:27 PM »

Sweet, thanks very much.

Just to get this straight, if there is nobody in the server, it will restart the bot and ftptail every minute since the logfile hasn't been updated, correct?
Logged
[ www.xlrstats.com ]
Project Lead
*
OS: Linux
Type: Owner dedicated server(s)
Gameservers: CoD, CoD2, CoD5, UrT
Posts: 2022
Offline Offline
WWW
Support Specialty: B3-Core, CoD/UrT/WoP/ETPro parsers, Plugin development
« Reply #11 on: May 17, 2009, 02:06:15 AM »

@Bakes: Is it okay to include these example scripts in the next release?
Logged

B3 Contrib/Support
*
OS: --No B3 installed--
Type: --No B3 installed--
Posts: 1225
Offline Offline
Support Specialty: B3-Core, CoD/BFBC2 parsers, FTP-functionality, Plugin development
« Reply #12 on: May 17, 2009, 05:41:26 AM »

Sure. They're mainly Courgette's work, though I can't see him minding. BTW, FTPtail does not have a license, so you can include it.
Logged

Jr. Member
**
Posts: 30
Offline Offline
« Reply #13 on: May 18, 2009, 12:45:00 PM »

Is there a reason this compares logfiles instead of using the status argument for the ftptail start script to see if it is still running?

These have been working great so far, except for that b3 crashed once and the main script never restarted it. I modded the scripts a bit to check the status of the b3 process every time it compares the logfile checksums and restart if the status says it's not running. Just wondering why it isn't doing it this way for ftptail. I can post my mods if anybody wants them.
Logged
B3 Contrib/Support
*
OS: --No B3 installed--
Type: --No B3 installed--
Posts: 1225
Offline Offline
Support Specialty: B3-Core, CoD/BFBC2 parsers, FTP-functionality, Plugin development
« Reply #14 on: May 18, 2009, 09:03:05 PM »

because for me it hung, rather than all out crashing.
Logged

Tags:
Pages: [1]   Go Up
  Print  
 
Jump to:  


Rate this page +1 at Google Search


SimplePortal 2.3.1 © 2008-2009, SimplePortal