Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PM2 dev and prod environments on same server

Tags:

node.js

pm2

I have a dev and prod instance of a microservice running on one machine. My ecosystem file gives them the same name. PM2 will not start the second instance when the first is running due to the name (presumably). Any ideas for a workaround here?

like image 660
Joe Flateau Avatar asked Feb 13 '26 09:02

Joe Flateau


1 Answers

Thanks for the help... I ended up with this:

require("dotenv").config();

module.exports = {
  apps: [
    {
      name: "app-" + process.env.environment,
      script: "./app.js",
      max_memory_restart: "150M"
    }
  ]
};
like image 82
Joe Flateau Avatar answered Feb 16 '26 00:02

Joe Flateau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!