Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. First, is by adding the "exec_mode" and "instances" settings to your JSON configuration as follows.  The "exec_mode" setting enables cluster mode, while the "instances" setting allows you to customize how many CPUs are available to PM2 ("max" = all CPUs, but you also can specify a number.)

    Code Block
    languagejs
    titledspace-ui.json
    {
        "apps": [
            {
               "name": "dspace-ui",
               "cwd": "/full/path/to/dspace-ui-deploy",
               "script": "dist/server/main.js",
               "instances": "max",
               "exec_mode": "cluster",
               "env": {
                  "NODE_ENV": "production"
               }
            }
        ]
    }

    Then, start (or restart) your site as normal (e.g. pm2 start dspace-ui.json)

  2. Alternatively, you can pass in the "-i" flag with either "max" or a number to tell PM2 to run in cluster mode across that many CPUs:

    Code Block
    # Start the "dspace-ui" app & cluster it across all available CPUs
    pm2 start dspace-ui.json -i max


...