Username: Password:

Author Topic: [BETA] Easiest way to start new Gunbot instances via shell  (Read 4305 times)

Offline densmirnov

  • Rookie
  • *
  • Posts: 7
    • View Profile
    • densmirnov.com
[BETA] Easiest way to start new Gunbot instances via shell
« on: June 09, 2017, 12:09:08 AM »
Hi! As you might know, PM2 is one of the best process managers for *nix right now. And it works perfectly with GunBot, but when you have multiple configs the process of starting new instance becames a bit complicated.

I've tried to make a simple solution, which allows you to start new GunBot instance (as long as you have PM2 installed and there is a config file present) with just a simple command (run it from gunbot folder): gunstart BTC_LSK poloniex !

This command will work exactly as this one: pm2 start -n BTC_LSK -o /home/gunbot/gunbot3/poloniex-BTC_LSK-log.txt -e /home/gunbot/gunbot3/poloniex-BTC_LSK-err.txt /home/gunbot/gunbot3/gunthy-linuxx64 -- BTC_LSK poloniex, which will start a new pm2 instance with config and error logs in correct places and will use correct gunbot version for your system architecture.

To install this command simply run curl -o- https://densmirnov.com/gunstart.sh | bash and voila you will be able to use gunstart command. Actually all this is just a simple script, which adds new function to your ~/.bash_aliases


P.S. Keep in mind, that this is very early release, possible full of bugs and glitches. Use it on your risk! But feel free to fix or change anything!

Offline AlfonseX

  • Contributor
  • **
  • Posts: 101
  • Trop de chefs, pas assez d'indiens !
    • View Profile
Re: [BETA] Easiest way to start new Gunbot instances via shell
« Reply #1 on: June 09, 2017, 01:09:25 AM »
I don't use PM2 (just a more process), and I use tmux to manage all my gunbot instances like this:

Code: [Select]
#!/bin/env bash
# start all *-config.js in a tmux new session

COMMAND="./gunthy-linuxx64"

flag="0"
for file in *-config.js; do
    pair=$(echo $file | cut -d'-' -f2)
    market=$(echo $file | cut -d'-' -f1)
    if [[ "$flag" = "0" ]]; then
        tmux -2 new-session -d -s gunbot -n $pair "$COMMAND $pair $market"
        flag="1"
    else
        tmux -2 new-window -d -n $pair "$COMMAND $pair $market"
    fi
    printf "Launching %s %s " "$market" "$pair"
    for i in {0..20}; do
        echo -n "."
        sleep 1
    done
    echo
done

echo Done

But you can simply launch all your config file (without using tmux) like this:

Code: [Select]
#!/bin/env bash

for file in *-config.js; do
    pair=$(echo $file | cut -d'-' -f2)
    market=$(echo $file | cut -d'-' -f1)
    ./gunthy-linuxx64 $pair $market
    sleep 20
    done
done

Save code in a file (like start.sh) and
Code: [Select]
chmod u+x start.sh then you can launch it with
Code: [Select]
./start.sh
Ok, PM2 is a great tool to keep an eye on your gunbots, but ps, top, htop, or my favorite glances (sudo pip install glances) don't eat my CPU.

My two cents ;)

Thank you for your work.
If you think I helped you, give me a drink:
in btc: 12aeQSpytxoehCEptQE8tUJVVSAS42LvXo
in eth: 0x02a611f0c15bccdb6fa8e5e4b0692ff6d77852bd