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



  • @Wolf u know what EC2 server phantombot can be implemented on 24/7?



  • @miguel747 like i said, i’m new to phantombot. and i’m certainly not linux savvy. that said, you could probly do it on your EC2 server. that should work, shouldn’t it? cheers m8!


  • Bot Developer

    Like Wolf has said, Amazon Linux doesn’t support systemctl or systemd. It uses sysinitv, which has been used for years in certain flavors of Unix. Any EC2 instance should be able to run PhantomBot 24x7, as long as it has enough memory available and CPU power. However, remember that you have only so many free credits to use before you have to start paying for service.

    Personally, while I don’t run PhantomBot in EC2, I do run several Tomcat instances for my company under t2.micro (dev/test) and t2.small (production) instances 24x7 and they run fine.

    If you are trying to keep PhantomBot running 24x7 and have it auto-restart, you might consider first adding a script to the sysinit system (/etc/init.d), and allow the system to auto-start the application. Another way you could do this is setup a cronjob that runs every few minutes with a script to see if PhantomBot is running based on the PID file it creates and then starting up the application if the application is not running as the PID in the PID file. This is basically what systemctl and systemd sort of do, you provide them with a PID file to monitor or a process name to watch, and they auto-restart as needed.

    Given the CPU and memory usage that PhantomBot has on my couple of Linux servers (one is in a data center, one at home), you probably want one with at least 1GB of memory to be safe, although you can probably get by with 512MB, depending upon what all features you enable and how busy your chat is. A busier chat requires more memory resources for PhantomBot to keep up with. A t2.nano provides 512MB of memory, the t2.micro provides 1GB of memory. So, if you have a small chat, and not enabling every feature, a t2.nano should be fine. If you have a fairly busy chat, I wouldn’t go any lower than a t2.micro with 1GB of memory.


  • 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.