A
A
Andrey Ivanov2019-08-18 18:08:46
Node.js
Andrey Ivanov, 2019-08-18 18:08:46

Why doesn't the site launch via pm2 in production mode?

Something I can not start the site through pm2, can someone tell me why? In development mode, the site is launched in production mode, no, pm2 logs are clean, like the process is running and everything is fine, but on page 404
Ecosystem

module.exports = {
  apps : [
    {
      name: "proto-dev.ru",
      cwd: './proto-dev.ru',
      script: "npm",
      args: "start",
      watch: true,
      env: {
        "NODE_ENV": "development",
      },
      env_production: {
        "NODE_ENV": "production",
      }
    }
  ],
};

server.js
const express = require('express');
const next = require('next');

const port = parseInt(process.env.PORT, 10) || 8000;
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();

package.json
"scripts": {
    "dev": "node server.js",
    "build": "next build",
    "start": "NODE_ENV=production node server.js"
  },

I run this commandpm2 restart ecosystem.config.js --env production

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question