Skip to content
Discussion options

You must be logged in to vote
  1. Install pm2 in the dependencies
  2. Make sure you have a package.json scripts section like this:
"scripts": {
  "dev": "next",
  "build": "next build",
  "start": "next start",
  "pm2": "pm2"
}
  1. Add pm2.json and add the following configuration:
{
  "apps": [
      {
          "name": "my-app",
          "script": "npm",
          "args" : "start",
          "instances": "max",
          "exec_mode": "cluster"
      }
  ]
}
  1. Make sure you run npm run build to build the Next.js app for production
  2. Run npm run pm2 start pm2.json

Note: pm2.json is doesn't have to have that exact name, it's just what I used while testing.

The configuration above will start as many instances as possible and fa…

Replies: 10 comments 32 replies

Comment options

You must be logged in to vote
3 replies
@choisium
Comment options

@vhadjiev
Comment options

@choisium
Comment options

Comment options

You must be logged in to vote
1 reply
@choisium
Comment options

Comment options

You must be logged in to vote
14 replies
@constsz
Comment options

@esmalleydev
Comment options

@quyphan97
Comment options

@esmalleydev
Comment options

@quyphan97
Comment options

Answer selected by Timer
Comment options

You must be logged in to vote
5 replies
@ong-ar
Comment options

@michaelschufi
Comment options

@magnnus
Comment options

@seungdols
Comment options

@chalermpong
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@asheroto
Comment options

@marnixhoh
Comment options

Comment options

You must be logged in to vote
3 replies
@hugw
Comment options

@smasilamani-cfins
Comment options

@EmitoSanti
Comment options

Comment options

You must be logged in to vote
3 replies
@stegano
Comment options

@saaiful
Comment options

@DuckThom
Comment options

Comment options

You must be logged in to vote
1 reply
@swarm-agent
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet