I hosted my bot in GCP so it will be 24/7 online and when I start the bot by using the SSH browser it starts normally but when I close the SSH tab my bot goes automatically offline. what's the solution behind this? My bot has no errors at all + I tried hosting it in repl.it and it works fine.
Asked
Active
Viewed 529 times
0
-
Are you using a process manager such as [pm2](https://pm2.keymetrics.io/)? – DJ001 Jul 14 '21 at 13:32
-
Already got a solution to this but thanks for helping out! – Dissolved Jul 14 '21 at 14:22
1 Answers
1
You should use a process manager like PM2. You can install it using NPM:
npm i -g pm2
That may require you to use sudo
. After installation head to your Discord bot's directory and run these commands:
pm2 start index.js
pm2 startup
pm2 save
Checkout PM2's documentation for detailed information.

Dharmaraj
- 47,845
- 8
- 52
- 84
-
-
-
@Dissolved you can use `pm2 stop
` (or go to that directory and `pm2 stop index.js` if you had specified file name). `pm2 delete` can be used to delete the process. If my answer was helpful, consider accepting it by clicking the tick icon :) – Dharmaraj Jul 17 '21 at 05:51