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



我正在尝试在本地PC上部署Next.js应用程序。

这是我的配置和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"
}
]
}

当我用命令启动应用程序时:

pm2 start ecosystem.config.json

弹出并关闭多个命令窗口(正好是11个窗口(然后有11个相同的应用程序正在我的电脑上运行。11个过程

删除1-10个进程不会影响应用程序。

我的配置有问题吗?还是一个错误?

感谢@Yash Kumar Verma的评论,

实例应该是运行应用程序时使用的大量硬件资源。

将实例从-1更改为1,运行良好

最新更新