Host your bot free 24/7 using amazon AWS service for a year.


  • Bot Developer

    Sample script to run from cron to check to see if PhantomBot is running as a service every minute and restart as needed:

    #!/bin/bash
    
    # Run this from crontab of the user that runs PhantomBot:
    # * * * * * /path/to/this/script/botServiceRunner.sh
    
    # Put the path to PhantomBot here
    PBOT_HOME=/opt/iobot
    
    # Put the name of your bot here that you use in botlogin.txt
    PBOT_NAME=illusionarybot
    
    # Function : startPhantomBot
    # Purpose  : Starts PhantomBot via the launch-service.sh script.
    function startPhantomBot {
        echo "Starting Bot"
        ${PBOT_HOME}/launch-service.sh
        exit 0
    }
    
    # Main Script
    
    PBOT_PID_FILE=${PBOT_HOME}/PhantomBot.${PBOT_NAME}.pid
    
    if [[ ! -d ${PBOT_HOME} ]]; then
        echo "That directory does not exist: ${PBOT_HOME}"
        exit 1
    fi
    
    if [[ ! -e ${PBOT_HOME}/botlogin.txt ]]; then
        echo "Does not appear to be a PhantomBot installation: ${PBOT_HOME}"
        exit 1
    fi
    
    if [[ ! -x ${PBOT_HOME}/launch-service.sh ]]; then
        echo "Script not found/not executable: ${PBOT_HOME}/launch-service.sh"
        exit 1
    fi
    
    if [[ ! -e ${PBOT_PID_FILE} ]]; then
        startPhantomBot
    fi
    
    PID=$(cat ${PBOT_PID_FILE})
    PID_INFO=$(ps -p ${PID} | grep -c java)
    
    if [[ ${PID_INFO} -ne "1" ]]; then
        startPhantomBot
    fi
    

    Copy/paste the script to botServiceRunner.sh, your home directory or the PhantomBot directory would be fine. Be sure to chmod +x botServiceRunner.sh after you create the file.

    Test it from the command line of course to make sure that you have the variables set correctly that I indicate that you need to set. Then you can have cron run the script every minute as indicated in the script. Yes, worst case, your bot is down for a minute if it dies or the instance reboots.



  • I personally use a windows 2012 instance for my AWS. Sure, I could use linux, but seeing as I’m only running one bot instance and it’s free for a year, that’s not something I’m worried about for awhile.

    The instance is only 1gb ram and on the t2.micro instance, which qualifies for the “free” tier.

    Haven’t had issues with it yet, but then again I’m hosting for a channel of 100-150 users peak. And setting up for a windows vps is like setting up for a windows pc, so most already know how to do it. The only additional step is adding the port rules to access it from outside the VPS, which some do as is.



  • @IllusionaryOne Thanks a mil for that contribution. I’m gonna get to work on implementing this.



  • @IllusionaryOne nice done. I will implement this and report later.


  • Bot Developer

    @miguel747 honestly if you use screen you can alt tab out of the window and close the console and the bot will run forever. usually try sudo screen then try launching the bot in that window



  • @PhantomIndex when i try to execute sudo screen with putty software it juss shows new screen and if i trey to close it says that sessions will close out.



  • @IllusionaryOne One question for now,

    Run this from the crontab of the user that runs PhantomBot:

    0,4,9,14,19,24,29,34,39,44,49,54 * * * * /path/to/this/script/botServiceRunner.sh

    I’m curious…will the above check every 5 minutes to see if PhantomBot is still executing in a normal fashion? And another question for anybody, how do you get the code section to appear for a post?



  • @IllusionaryOne THANKS U SO MUCH. i add this script into the crontab (root) and my bot runs ever. Nice job man.



  • @Wolf try this 0-59/5 * * * * root /home/yourBotPath



  • @miguel747 thanks man, i’ll definitely check on that.



  • well, i starting to think the hard part is over. got my crontab created and i have reason to believe it is executing normally.

    one thing i am having trouble with is the phantombot control panel. not sure what is wrong there. would be nice to get that working. have tried to reach it with ie 11 and chrome. followed the examples above. any suggestions for me to try?



  • @miguel747 your version most likely would have worked. i ended up using:

    */5 * * * * /path/myBotPath based on some info i found.



  • i have managed to find one error so far. was using this:

    http://w.x.y.z:25005/cpanel

    and you can see what’s wrong with that, laff. there’s some other issue which i haven’t been able to spot. i can PayPal $20 USD if someone feels like looking into this for me.



  • @Wolf ok…the control panel is now working. don’t ask me how i fixed it, because i have no friggin clue. it just works. the PayPal offer, it appears the deal is off. it is a glorious Friday. thanks again @IllusionaryOne for the help with gettin this set up.


  • Bot Developer

    @Wolf said in Host your bot free 24/7 using amazon AWS service for a year.:

    Run this from the crontab of the user that runs PhantomBot:
    0,4,9,14,19,24,29,34,39,44,49,54 * * * * /path/to/this/script/botServiceRunner.sh
    I’m curious…will the above check every 5 minutes to see if PhantomBot is still executing in a normal fashion? And another question for anybody, how do you get the code section to appear for a post?

    Yes, it will check every 5 minutes. You can also do */5 to make it look neat. (I see you figured that out)

    Be sure to change the path! For example, if you put the script under /home/bot you would put /home/bot/botServiceRunner.sh

    Use 3 backticks (`) in a row to enable the markdown.


Log in to reply
 

Looks like your connection to PhantomBot Community Forums was lost, please wait while we try to reconnect.