running multiple bots from one budabot installation

Questions, comments, suggestions, and bug reports
Tyrence
Posts: 1891
Joined: Sat Jan 09, 2010 1:32 am

running multiple bots from one budabot installation

Postby Tyrence » Wed Apr 21, 2010 8:09 pm

A while ago I made a change so that the config.php that the bot uses is passed as a param when you run the bot.

This allows you to run multiple bots from the same Budabot folder, but still have separate configs, and optionally share a database which might be handy for people who run linked org bots.

This change is in version 0.6.6.

Steps to use this:
1) make a copies of chatbot.bat (chatbot.sh if you're on Linux) for each bot you plan to run and rename them to something meaningful (eg, bot1.bat, bot2.bat)
2) open up each file you just copied and change "config.php" to something meaningful (eg, bot1config.php, bot2config.php)
3) make a copy of config.php and rename it to the names you specified in step 2) (eg, bot1config.php, bot2config.php)
4a) open each config file you copied in step 3 and set the properties for each bot. If you are linking two orgs bot, then you will want to share the database and it defaults to this so you don't need to do anything more. However, if you want them to use separate databases, you must put a unique database name in each config.php file on line 52:

Code: Select all

$settings['DB Name'] = "bot1.db";

Code: Select all

$settings['DB Name'] = "bot2.db";

etc. Of course if you are using MySQL you will have to change all the database settings to match your setup.

4b) If you don't want to configure the bots by editing the config.php file as outlined in 4a), you can instead run each bot, and walk through the on-screen setup. Note, that when it asks you to set up the database manually, you will need to say yes if you don't want the database to be shared among bots and then choose a unique database name for each bot.

That's it. You should then be able to run all your bots from one folder. When it comes time to upgrade or add new modules, you can do it in one place and it will upgrade all the bots you are running.

Note, when sharing the database, I do not know the implications of starting multiple bots at the same time due to the drop and reload of many of the tables during startup. I would recommend starting each bot one at a time until they are all running.
Last edited by Tyrence on Thu May 27, 2010 6:50 pm, edited 2 times in total.
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
Arsenal
Member
Posts: 224
Joined: Tue Mar 09, 2010 7:40 pm

Re: running multiple bots from one budabot installation

Postby Arsenal » Wed Apr 21, 2010 8:20 pm

Hmm that comes in quite handy for me, I already run multiple bots from a single installation with version 0.6.5.
That took a few moments to get it to run though.. Basically I used symlinks for everything except the config and the log-directories.

Which leads me to my question: How is logging handled? It's quite useful for debugging what's going on if I'm not around. Are there seperate logfiles in the log-directory, are there multiple log-directories, or did I hit a blind spot?
Tyrence
Posts: 1891
Joined: Sat Jan 09, 2010 1:32 am

Re: running multiple bots from one budabot installation

Postby Tyrence » Wed Apr 21, 2010 8:31 pm

hmmm that is something I did not even think of. Right now they will all log to the same file.

Maybe adding another setting in config.php for where to place the log files would be best. Default it to "./logs", or we could even default it to "./logs/$botname".....?
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
Snakebite
Site Admin
Posts: 246
Joined: Mon Nov 23, 2009 11:19 pm

Re: running multiple bots from one budabot installation

Postby Snakebite » Thu Apr 22, 2010 4:35 pm

Tyrence wrote:Note, when sharing the database, I do not know the implications of starting multiple bots at the same time due to the drop and reload of many of the tables during startup. I would recommend starting each bot one at a time until they are all running.


Ok, I think I understood most of that lol, howeve, this last bit...

Would it be possible to write a bot startup for the whole folder which boots them in alphabetical (or other option) order?

Kind of a 'Boot my bots' doobery, basicaly once you've updated them or whatever, just hit it and it will start all the bots in that single folder.. Make any sense?
Arsenal
Member
Posts: 224
Joined: Tue Mar 09, 2010 7:40 pm

Re: running multiple bots from one budabot installation

Postby Arsenal » Thu Apr 22, 2010 4:41 pm

In linux this will be a fairly easy shellscript I believe, just something like doing ls to get the startscripts into an array, then a simple for each loop with a delay between each startup, and you're done.
But don't ask me for actual code please :)
I don't know if the same thing is possible with windows batchfiles though.
Tyrence
Posts: 1891
Joined: Sat Jan 09, 2010 1:32 am

Re: running multiple bots from one budabot installation

Postby Tyrence » Thu Apr 22, 2010 6:51 pm

In windows, you can use "start your_cmd" to spawn multiple bots with one command

create a file called startAllBots.bat (or whatever you want) and put something simliar to this in it:

Code: Select all

start chatbot1.bat
start chatbot2.bat
start chatbot3.bat


I never looked into adding a delay, but it looks like that is covered here:
http://www.computerhope.com/batch.htm#4

The command is kinda ugly tho...

Another option I saw involved using "ping" to delay execution <g>
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
BarkinMad
Member
Posts: 1
Joined: Wed Jun 01, 2011 10:21 pm
antispam: Rimor

Re: running multiple bots from one budabot installation

Postby BarkinMad » Sun Jun 05, 2011 10:35 pm

here's a way to run multiple bots in widows at the same time, albeit w/o a delay. you will need to put the code below in a batch file:

Code: Select all

for %%* in (chatbot*.bat) do start /d .\Budabot2.2_GA_build1348\ %%*


then save that file in the parent folder of the folder where budabot is installed. next, go where main.php is located and create any number of chatbot<something, can even be null>.bat files that start each bot instance. after that, go back to where you have the batch file with the code above. here, create several empty files named chatbot<something, can even be null>.bat. here's an example:

budabot is installed in C:\BarkinMad\Budabot2.2_GA_build1348\. this is where the main.php file is located. we create chatbot.bat, chatbot1.bat, and chatbot2.bat in this folder, containing all the info needed to properly start 3 different bots. then we put test.bat, containing the code i have provided above, in C:\BarkinMad\ along with 3 empty files named chatbot.bat, chatbot1.bat, and chatbot2.bat. finally, we run test.bat, which will instantly start all 3 bots and, if necessary, run us through the initial setup process.


note: this has been tested under windows vista home basic, though it should be compatible with most versions of windows. also, i STRONGLY recommend that you have SOMETHING in place of chatbot in (chatbot*.bat), other than just a wildcard or it will also attempt to run test.bat, which we want to avoid(worst case scenario, it'll become an infinite loop. the other option is that you'll get an error and nothing will be run. since each version of windows has it's own quirks when it comes to batch files, let's not tempt fate)
User avatar
Shelly
Member
Posts: 81
Joined: Wed Oct 05, 2011 1:51 am
antispam: Rimor
Location: Lost in Time
Contact:

Re: running multiple bots from one budabot installation

Postby Shelly » Mon Feb 18, 2013 3:11 pm

I know this topic is a little old, but wanted to share a script I wrote a long time ago to start bots on Linux.

Code: Select all

#!/bin/bash
# start_<botname>
# By Shelly Targe
#
##
### 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 someone_who_cares, BOTNAME & BOTHOME items you will need to configure for your bot.
BOTHOME="/home/bot/<combined bot home>"
BOTNAME="<your bot character name>"
someone_who_cares="someone@somewhere.com"
#
# This can be configured for someplace else or left default
BOTLOGS=${BOTHOME}
BOTLOG_Archive=${BOTLOGS}/logs

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 " ${someone_who_cares} <${BOTLOGS}/${BOTNAME}.log ;
  if [ -e "${BOTLOGS}/${BOTNAME}.log-${mdate}.gz" ]
  then {
    mv ${BOTLOGS}/${BOTNAME}.log ${BOTLOG_Archive}/${BOTNAME}.log-${mdate};
    /bin/gzip ${BOTLOG_Archive}/${BOTNAME}.log-${mdate};
  }
  else {
    mv ${BOTLOGS}/${BOTNAME}.log ${BOTLOG_Archive}/${BOTNAME}.log-${hdate};
    /bin/gzip ${BOTLOG_Archive}/${BOTNAME}.log-${hdate};
  };
  fi
  cd ${BOTHOME}; /usr/bin/php -f ${BOTHOME}/mainloop.php ${BOTHOME}/conf/${BOTNAME}_config.php 2>&1 > ${BOTLOGS}/${BOTNAME}.log &
}
fi

#EOF
Your type personality is: SAEK
Breakdown: Socializer 73.33%, Achiever 60.00%, Explorer 60.00%, Killer 6.67%

http://en.wikipedia.org/wiki/Bartle_Test

Return to “General”

Who is online

Users browsing this forum: Mangoo and 1 guest