How to use PM2 CLI on Heroku
Asked Answered
M

2

10

I'm trying to use pm2 on Heroku. I did have a look at the documentation. It looks like the application works fine once deployed, and the logs indicates that multiple instances has started on a 2X dyno.

Yet when I run: heroku run bash and do a pm2 ls I get an empty list:

┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬────────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
└──────────┴────┴──────┴─────┴────────┴─────────┴────────┴────────┴──────────┘

And I can't use any pm2 CLI functions. I understand that when I do a heroku run command a one-off dyno is created on the fly and the pm2 instance running on this dyno does not run any process.

However I don't see how I can access pm2 on a specific dyno.

Is there any way to take advantage of the pm2 cli on Heroku?

May answered 25/8, 2015 at 14:34 Comment(0)
H
4

As mentioned in the Heroku docs,

your app is spread across many dynos

As a result there isn't one place your app is running so I can't see how you will be able to do what you want.

Heroku's docs explain this a bit more.

Headlight answered 29/4, 2016 at 11:56 Comment(0)
V
2

heroku run connects you to an additional temporary container.

To connect to a real running app container, use heroku ps:exec.

Veil answered 29/5, 2020 at 9:34 Comment(1)
this worked for me, can see all 8 processes. thanks!Temperate

© 2022 - 2024 — McMap. All rights reserved.