collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: restarting bot on *nix  (Read 2662 times)

0 Members and 1 Guest are viewing this topic.

Offline toxicman

  • BeBot Rookie
  • *
  • Posts: 5
  • Karma: +0/-0
restarting bot on *nix
« on: February 09, 2009, 02:29:58 am »
Hello!
I ran bebot on windows w/o any probs untill i got a new server that has FreeBSD as OS, and it was really tricky to set up and start the bot there :) but finally i managed to do it...

There's one lil problem though. On windows when bot LD's it restarts automatically.. And on *nix it just says "The bot is restarting" and exit program.

i found a solution for that, but i believe there's a better way to solve it.

i've put painbot.sh in rc.d:


Code: [Select]
#!/bin/sh

./etc/rc.subr

name="painbot"
start_cmd="${name}_start"
stop_cmd=":"

painbot_start()
{
echo "Starting painbot..."

counter=0
while [ $counter -lt 20 ];
do
let counter=counter+1
cd /painbot
/usr/local/bin/php /painbot/Main.php > /dev/null
echo Login attempt $counter finished.
done
}

load_rc_config $name
run_rc_command "$1"

that does the thing.. but its limited, and not correct way to do it.. also if i put $ in the end to hide the process from user, it just starts 20 bots in the same time..

Please help the noob *nix user! :D

thanks!

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: restarting bot on *nix
« Reply #1 on: February 12, 2009, 01:26:43 am »
http://bebot.link/bebot-0-6-support/linux/msg11624

http://bebot.link/bebot-0-6-support/how-to-recall-logginf-screen-of-bebot-(ssh)/msg12028

The best way to go about setting up the bot on a *NIX box is to use screen (http://www.gnu.org/software/screen/) to manage the bot.

I do:

screen -dmS botname php StartBot.php

I wouldn't do it from rc.d, unless you have set things up to run as a non-root user.


Here's a script you can put into cron to start the bot for you automatically:
Botname.sh
Code: [Select]
#!/bin/sh
#Crontab written for BeBot

botname="Botname"
pattern="php Botname.php"
botdir="/home/user/Botname"
command="/usr/bin/screen -dmS Botname /usr/bin/php botname.php"

if ps x | grep "$pattern" | grep -v grep
then
        echo $botname "is still running."
        exit 0
else
        echo "Starting "$botname
        cd $botdir
        $command
        exit 1
fi

Create a Botname.php file in the same directory as StartBot.php:
Code: [Select]
<?php
    
require_once('StartBot.php');
?>


Crontab entry would look like:
*/15 * * * * /path/to/Botname.sh

Cron will run the script every 15 minutes.

Offline toxicman

  • BeBot Rookie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: restarting bot on *nix
« Reply #2 on: February 12, 2009, 11:37:50 pm »
thanks for the detailed answer :D i will try it when i have time!

Offline toxicman

  • BeBot Rookie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: restarting bot on *nix
« Reply #3 on: February 13, 2009, 09:13:04 pm »
hey! i've done it all like you said,
everything works fine,
but my bot doesnt wana start on StartBot.php.. even w/o those scripts i do
'php StartBot.php' and nothing happens, just blank string.
bot starts ok with 'php Main.php' .. whats the difference between those two? and any clue how to fix that ?

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 531
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal