PM2 Not working with v5

I have an ecosystem.config.js file that is:

module.exports = {
  apps : [
  {
    name      : "peble api",
    script    : "server.js",
    instances : "1",
    exec_mode : "fork",
    env: {
      NODE_ENV: "production",
      PORT: 1337
    }
  }
]}

And the server.js file:

// path: `./server.js`

const strapi = require('@strapi/strapi');
strapi().start();

This is throwing a bad gateway error - however when I simply run npm run strapi start or npm run strapi develop, things run perfectly.

ANy guidance would be great.

This topic has been created from a Discord post (1287458230301102151) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

1 Like

Adding to this:

If I run the command

NODE_ENV=production pm2 start 'npm run strapi start' -n 'api service'

And then

pm2 save

Things work fine. However, I’d really like to use an ecosystem.config.js file so if anyone has any insights here I’d appreciate!

1 Like