Using pm2 to deploy multiple node. js projects, pm2node. js
Preface
I believe everyone knows that in actual project deployment, the node service needs to be automatically started when the server is started. Previously, it was started using the built-in commands of liunx. However, as the number of backend microservices increases. Each time a new program is released. It is too troublesome to modify the script. So we can change it to pm2. I will not talk about it much below. Let's take a look at the detailed implementation process.
The configuration method is as follows:
1. First install pm2
Npm install-g pm2
2. Generate a configuration file
Pm2 ecosystem
After the generation is complete, an ecosystem. config. js file will be generated,
3. modify the configuration file
Edit ecosystem. config. js
. The master needs to configure the program name, the program STARTUP script. You can.
4. Start the configuration file
Pm2 startOrRestart ecosystem. config. js
5. view the startup status
Pm2 list
Indicates that the program is successfully started.
The script startup command can be combined with nvm to support multiple node versions.
Summary
The above is all the content of this article. There are still many shortcomings in this article. I hope this article will have some reference and learning value for everyone's learning or work. If you have any questions, please leave a message, thank you for your support.