This tutorial we will see how to run Botpress in background so even if you log out from the terminal, Botpress runs as a background process.
Botpress is a node process, which needs another process to help itself run as a separate background process. We have been running Botpress in production without any difficulty using the pm2 tool. It is a daemon process manager that helps in managing and keeping your application online, even when the Botpress process goes down and will automatically take care of restarting the process.
Installing and using PM2
Install pm2 using below command
npm install pm2 -g
Start Botpress as a background process
pm2 start './bp start -p'
You can also use below commands to manage Botpress process, the option names are self explanatory
pm2 list pm2 logs pm2 start './bp start -p' pm2 reload './bp start -p' pm2 stop './bp start -p' pm2 delete './bp start -p'
Botpress officially supports using pm2 tool for high resilience.
4 Comments
kenneth kaigu · March 11, 2020 at 10:58 pm
What if you say./bp start $ bg in a Linux server ? would it still work?
Simon · March 12, 2020 at 10:10 am
@kenneth It is advisable to use a process manager to run a node process in background. Example tools forever and pm2. They will automatically detect and restart if the process is down. In my case the Botpress server was always going down after sometime, once I used pm2 the Botpress server never went down, even till today.
Ricardo · August 21, 2020 at 3:18 am
Is necessary to specify anything to restart the services when reboot server?
Simon · August 21, 2020 at 2:26 pm
@Ricardo: I never tried it, but if the server is rebooted then I think you need to restart PM2 or else run PM2 as a service, so that is starts automatically after the server restarts.