BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Age of Conan Archive => BeBot Hyborian support => Topic started by: tsafarog on November 10, 2010, 11:45:04 am

Title: Starting Bot as a service on a Linux system
Post by: tsafarog on November 10, 2010, 11:45:04 am
Hello guys,

need your help

I am running the Bot through an SSH client always by giving the php5 command. The problem is that when my SSH client crash for a reason the Bot disconnects. Is there a way to start the Bot as a service so i wont have to relog when the Bot crash and will not have to pay so much attention to it??

Thank you in advance
Title: Re: Starting Bot as a service on a Linux system
Post by: Getrix on November 10, 2010, 12:53:19 pm
Have a look on "screen" function in linux
Title: Re: Starting Bot as a service on a Linux system
Post by: Yite on November 10, 2010, 12:55:51 pm
Yup works great in screens (running multiple bots each in their own 'screen') for some more information check out Getrix' comments here: http://bebot.link/ao-0-6-support/how-to-recall-logginf-screen-of-bebot-%28ssh%29/msg12028/#msg12028
Title: Re: Starting Bot as a service on a Linux system
Post by: tsafarog on November 10, 2010, 01:04:58 pm
i know what you mean....

But my problem is for example when i am away from home ..... i dont want to have my pc running putty all the time. What if it crashes when i am not home? I am not familiar with the screen command. If i setup screen, will i be able to close SSH and bot will keep running???

Title: Re: Starting Bot as a service on a Linux system
Post by: Yite on November 10, 2010, 02:28:21 pm
yeah basically what you do is you create a screen session (from memory screen -s sockname)

In this session you will start your bot
to leave the screen session press ctrl-a ctrl-d (or just ctrl-a d can't remember)

At any point you want to check up on the session run:
screen -r name (or just screen -r to see a list of screens)

If your ssh session dies your bot will keep on running.
Title: Re: Starting Bot as a service on a Linux system
Post by: tsafarog on November 12, 2010, 10:47:15 am
Thank you very much for your help problem solved
Title: Re: Starting Bot as a service on a Linux system
Post by: Shelly on September 25, 2011, 10:56:39 pm
If you are only running a single bot... you can also do

to keep a log:
nohup /usr/bin/php -f <bothome>/StartBot.php <botname> 2>&1 > <bothome>/<botname>.log &

or to maintain space:
nohup /usr/bin/php -f <bothome>/StartBot.php <botname> 2>&1 > /dev/null &

I use a script to start my bots so I don't have to remain logged into the server...
start_<botname>.sh
Code: [Select]
#!/bin/bash
 
#
##
### Check for AO Bots and restart if necessary
##
#
# This script looks to see if your bot is actually running and does nothing if it is
# already running.
# If it is not running, it will email you the previous log, then compress it to concerve space.

# The BOT* items you will need to configure for your bot.
BOTHOME="/home/bot/BeBot"
BOTNAME="Your_Bot_Character_Name"
BOTLOGS="/home/bot"
BOTLOG_Archive=${BOTLOGS}/log_archive

mdate=`date +%b-%d-%Y`;
hdate=`date +%b-%d-%Y_%H%M_hrs`;

z=`ps -ef |grep ${BOTNAME} |grep -v grep`;
if [[ $z == "" ]]
then {
  # comment this next line out if you don't want the previous log emailed to you.
  mailx -s "Starting ${BOTNAME} bot " [email protected] <${BOTLOGS}/${BOTNAME}.log ;
  if [ -e "${BOTLOGS}/${BOTNAME}.log-${mdate}.Z" ]
  then {
    mv ${BOTLOGS}/${BOTNAME}.log ${BOTLOG_Archive}/${BOTNAME}.log-${mdate};
    /usr/bin/compress ${BOTLOG_Archive}/${BOTNAME}.log-${mdate};
  }
  else {
    mv ${BOTLOGS}/${BOTNAME}.log ${BOTLOG_Archive}/${BOTNAME}.log-${hdate};
    /usr/bin/compress ${BOTLOG_Archive}/${BOTNAME}.log-${hdate};
  };
  fi
  cd ${BOTHOME}; /usr/bin/php -f ${BOTHOME}/StartBot.php ${BOTNAME} 2>&1 > ${BOTLOGS}/${BOTNAME}.log &
}
fi

#EOF
SimplePortal 2.3.7 © 2008-2024, SimplePortal