简体   繁体   English

pm2 启动许多重复的 next.js 应用程序

[英]pm2 starts many duplicated next.js apps

I'm trying to deploy Next.js app on local PC.我正在尝试在本地 PC 上部署 Next.js 应用程序。

here's my configuration and package.json files.这是我的配置和 package.json 文件。

// package.json
{
  "name": "smarf",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "axios": "^0.25.0",
    "modbus-serial": "^8.0.5",
    "mongoose": "^6.1.7",
    "next": "12.0.8",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "swr": "^1.1.2"
  },
  "devDependencies": {
    "autoprefixer": "^10.4.2",
    "eslint": "8.7.0",
    "eslint-config-next": "12.0.8",
    "postcss": "^8.4.5",
    "tailwindcss": "^3.0.15"
  }
}
// ecosystem.config.json
{
  "apps": [
    {
      "name": "smarf",
      "cwd": "./",
      "script": "node_modules/next/dist/bin/next",
      "args": "start",
      "instances": -1,
      "exec_mode": "cluster",
      "autorestart": false,
      "max_memory_restart": "2G",

      "output": "~/logs/pm2/console.log",
      "error": "~/logs/pm2/onsoleError.log"
    }
  ]
}

When I start app with command:当我使用命令启动应用程序时:

pm2 start ecosystem.config.json

multiple command windows(which is exactly 11 windows) pops up and closes then there are 11 same application is running on my computer.多个命令窗口(正好是 11 个窗口)弹出并关闭,然后我的计算机上运行了 11 个相同的应用程序。 11 processes 11道工序

Deleting 1-10 processes does not affect application.删除1-10个进程不影响申请。

Did I something wrong with the configuration or is it a bug?我的配置有问题还是错误?

Thanks to @Yash Kumar Verma's comment,感谢@Yash Kumar Verma 的评论,

instances should be a number of hardware resources used while running the app.实例应该是运行应用程序时使用的一些硬件资源。

changing instances from -1 to 1, it works well将实例从-1更改为1,效果很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM