-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create duplicate services when using PM2 with next.js #5197
Comments
@jim-king-2000 would you mind to explain it a little? I'm using nextjs v7 with PM2, and I use the It looks like this: //pm2.config.js
module.exports = {
apps: [
{
instances: 1,
max_restarts: 10,
merge_logs: false,
script: './index.js',
max_memory_restart: '200M'
}
]
}; We also deploy our app using a Docker image. We run this file using Hope this helps! |
@jim-king-2000 try running in the following way: pm2 start npm --name "myproj" -- start -i 1 |
I use pm2.json like the following: {
"apps": [
{
"name": "fe-fireeye",
"script": "./pm2Server.js",
"exec_mode": "fork",
"instances": 1,
"node_args" : "-r esm",
"env": {
"NODE_ENV": "production",
"NODE_PORT" : "8090"
},
"max-memory-restart": "300M"
}
]
} Then I type 0|fe-fireeye | > Could not find a valid build in the 'D:\projects\location-service-fireeye\fe-fireeye.next' directory! Try building your app with 'next build' before starting the server. |
Did you run |
It works. I'm so sorry. The error message is the old one. I see the old error and do not try to access the server. I close the thread. It is a false alarm. |
🙏 great! |
In the projects not using next.js, we use "pm2 start pm2.json. It never generates duplicate pm2 instances.
When using PM2 with next.js, we can't use pm2.json configuration file. The code is like the following:
// package.json
"start": "node --experimental-modules server.mjs"
// deploy.sh
pm2 start npm --name "myproj" -- start
When I run deploy.sh without deleting the existing "myproj" pm2 instance, there would be two "myproj" instances. And it disables the auto-deployment script.
Looking forward to the answer.
The text was updated successfully, but these errors were encountered: