The company’s project portal is using nuXT framework development, do SEO things, and also need load balancing self-start project, to sort out how pM2 is configured to achieve self-start.

I have attached some links to the documents I saw before, so I can get to know them first

Nodejs thread management in Windows PM2 starts automatically upon startup

Pm2 management applications run as Windows services

Nuxt static nuxt.config.js package.json. env (the.env file is the environmental decision file in my project) on the server, and then install pM2

  1. Install pM2 on the server: NPM I PM2 -g

  2. NPM install pm2-windows-startup -g Install the Windows startup package

  3. M2 -startup install Run the command

  4. Pm2 start “C: Program Files\nodejs\node_modules\ NPM \bin\ NPM -cli.js” — run dev

  5. The pm2 save step generates the dump.pm2 file

  6. NPM i-g pm2-windows-service

  7. Add the system environment variable PM2_HOME=D:.pm2

  8. Open a new command line window as an administrator and run the pm2-service-install command to install the service

  9. Perform environment setup ? N, to continue

  10. Pm2 -service-uninstall Uninstall pM2 -service-uninstall pM2 -service-uninstall Pm2 pM2 pM2 pM2 pM2 pM2 pM2 pM2 pM2

    Pm2 ls # Check the process list

    Pm2 delete all # kill all processes.

And the rest is just copy and paste and look at it

$NPM install pm2 -g #

$pm2 start app.js – I $pm2 start app.js – I

The correct number of processes depends on the number of cores in the CpuCopy the code

$pm2 start app.js –name my-api

$pm2 list # display all process status

$pm2 monit # Monitor all processes

$pm2 logs # Display all process logs

$pm2 stop all

$pm2 restart all processes

$pm2 reload all # 0 seconds stop overloaded processes (for NETWORKED processes)

$pm2 stop 0 # Stop the specified process

$pm2 restart 0

$pm2 startup # create init script to keep process alive

$pm2 Web # Run a robust Computer API endpoint (http://localhost:9615)

$pm2 delete 0 # Kills the specified process

$pm2 delete all

$pm2 start app.js -i Max # Specifies the maximum number of processes to start based on the number of available cpus

$pm2 start app.js -i 3 # Start 3 processes

$pm2 start app.js -x # start app.js in fork mode instead of cluster

$pm2 start app.js -x — a 23

$pm2 start app.js –name serverOne # Start a process and name it serverOne

$pm2 stop ServerOne # Stop serverOne

$pm2 start app.json # Start the process, set the options in app.json

$pm2 start app.js -i Max — a 23 # pass parameters to app.js after —

$pm2 start app.js -i Max -e err.log -o out.log # Start and generate a configuration file