Running gekko in the background with PM2
#1
Hello,

I noticed that quite a lot of users run gekko in a screen process to keep it running while they are logged off. But there's a better way, use PM2!

The installation is quite simple:
Code:
npm install pm2 -g
Ubuntu/Debian users might want to run it with: sudo

Now that you have pm2 installed, there's just one more step to start gekko:

For CLI bots use:

Code:
pm2 start gekko.js -n "yourNameHere" -- -c my_config.js

To run the UI use:
Code:
pm2 start gekko.js -n "ui" -- --ui

Everything after the doubledash is passed as an argument to the gekko.js process. The parameter -n names your process. You have to give every instance a name, otherwise pm2 will refuse to start more than one instance of gekko.

To list all running processes use:
Code:
pm2 list

To stop a process use:
Code:
pm2 stop [id|name]
for instance:
pm2 stop 0
or
pm2 stop ui

Once a process is stopped you can remove it from the list using:

Code:
pm2 delete [id|name]

for instance:
pm2 delete 0
or
pm2 delete ui


PM2 stores the output of each process in your users homedir in ~/.pm2/logs. You can watch the logs with:
Code:
pm2 logs
or
pm2 logs [id|name]
to watch a specific process


I hope this helps anyone who's stuck in a hell of running a bunch of screen processes in parallel.

Tips are welcome:
ETH 0x40ddba96695bc040ccbe34b4cfa3a7ae8f225583
 
  Reply
#2
Thanks again it is very useful.... 
i tried it and it is working.. the one thing i still need is: 
Can I access a running process on pm2 node to give it a command or string, or just to interact with it.
For example i have a backtest that always asks to choose an option of 2 different histories I have for the same pair and exchange, and after you start it, it asks me to choose a database... 
on screen or so i can just go there and till it to choose, but on PM2 ??? 

Would be nice to know how... 
thanks.
  Reply
#3
Thats a nice tutorial

I use VNC-Viewer for my headless Raspberry pie.
This allows me to have the DESKTOP VERSION of raspbian ON eny LAPTOP!!!
EVEN WORKS WITH VPN (after setup VNC)
No need for monitor/mouse/keyboard

Looks good the display size can be choosen.
  Reply
#4
(02-13-2018, 06:32 PM)susitronix Wrote: Thats a nice tutorial

I use VNC-Viewer for my headless Raspberry pie.
This allows me to have the DESKTOP VERSION of raspbian ON eny LAPTOP!!!
EVEN WORKS WITH VPN (after setup VNC)
No need for monitor/mouse/keyboard

Looks good the display size can be choosen.

Same here - it's the most comfortable way IMHO
  Reply
#5
Hello,

Is it possible to start the UI with PM2 while at the same time starting a live strategy once that UI is launched?

I like being able to view the round trips within the UI, while at the same time running multiple strategies/gekkos at once. As far as I know the command line doesn't produce a nice round trip/trade log.

I like the idea of PM2 restarting a strategy if one happens to die within gekko, but would like to run them within the UI.

OR, is it possible to start a strategy in command line with PM2 and then open the UI in a browser a few days later and see all the round trips for a live strategy that has already been running?

Thanks!
  Reply
#6
Nice. I use forever to run gekko:

forever start -a ~/gekko/gekko.js --ui
forever stop ~/gekko/gekko.js --ui

-a flag is to keep a log.

Do you keep multiple gekkos running as CLI?
  Reply
#7
I attached small bash script to restart, stop and start many ids from pm2 with random interval to desync tickrate (avoid ban). ids are in bots.conf one entry on one line.


Attached Files
.zip   botnet.zip (Size: 759 bytes / Downloads: 56)
My projects [Strategies] [Datasets]
  Reply
#8
@ Sirtificate
...i have miss understood what PM2 is, thanks nice tut
  Reply
#9
(05-21-2018, 02:50 AM)ankasem Wrote: @ Sirtificate
thank you

We started as pm2 cli
ubuntu server is down
when ubuntu server is opened
How to start pm2 at boot time

I am rather sure this user is asking how to get gekko to auto run at boot. I have the same question. Can anyone help?
  Reply
#10
(05-21-2018, 06:03 PM)pingywon Wrote:
(05-21-2018, 02:50 AM)ankasem Wrote: @ Sirtificate
thank you

We started as pm2 cli
ubuntu server is down
when ubuntu server is opened
How to start pm2 at boot time

I am rather sure this user is asking how to get gekko to auto run at boot. I have the same question. Can anyone help?

https://github.com/askmike/gekko/wiki/Ge...th-Systemd
  Reply


Forum Jump:


Users browsing this thread: