module.exports = {
apps : [{
name: "nextjs-app",
script: "npm",
args: "run build",
env: {
NODE_ENV: "production"
}
}]
};
但是当我跑步时,终端给了我这样的呼吸:
pm2 start npm -- start
但是,当我尝试查看过程列表时,没有,当用户尝试输入网站时,网站日志显示端口3000没有服务
pm2 start npm -- start
[PM2] Spawning PM2 daemon with pm2_home=/home/georgianar/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /usr/local/bin/npm in fork_mode (1 instance)
[PM2] Done.
和
(111)Connection refused: AH00957: http: attempt to connect to 127.0.0.1:3000 (localhost:3000) failed
我不知道为什么,任何人知道为什么这样做?
如果您只想使用PM2运行已经部署并构建的下一个应用程序,则不需要生态系统文件。
即将从项目根文件夹运行:AH01114: HTTP: failed to make connection to backend: localhost
您的文件应该像这样:
pm2 start npm --name "app_name" -- start
ecosystem.config.js
.这里的关键要点是,
module.exports = {
apps: [
{
name: "your-app-name",
// path to `next` from `node_modules` (the lack of `./` at the start of the path is on purpose)
script: "node_modules/next/dist/bin/next",
args: "start",
env_production: {
NODE_ENV: "production",
},
// ...other config
},
],
};
值应指向pm2 startOrReload ecosystem.config.js --env production
。