当前位置:网站首页>Win configuration PM2 boot auto start node project
Win configuration PM2 boot auto start node project
2022-07-07 05:44:00 【Bitter sea 123】
pm2 Be similar to nodemon, But the functional ratio nodemon Richer
1. Global installation pm2, If your system is not installed in advance node Environmental Science , Then you can refer to the blog :https://blog.csdn.net/weixin_46758988/article/details/117109297 ; If you have installed globally pm2, It's just that there is no configuration for boot auto startup , Then you don't need to repeat the installation pm2 了
npm install pm2 -g Or use yarn install ( Use yarn before npm install yarn -g Global installation yarn):yarn global add pm2
2. Global installation pm2 Win Self opening package :pm2-windows-startup:
npm install pm2-windows-startup -g or yarn global add pm2-windows-startup
3. Install configuration package :pm2-startup
pm2-startup install or yarn add pm2-startup
4. Use pm2 Start project , Here you can directly start the index.js or app.js, But it is still recommended pm2 Profile launch project , About pm2 The configuration file can refer to the following configuration file pm2.config.json( If you want more detailed configuration, you can consult the official documents ):
{
"apps":{
"name":"myproject-web", // Alias of the item
"script":"index.js", // Need to start the program's entry file
"watch":"true", // Enable file change monitoring
"ignore_watch":[ // Ignore file changes and listen for files
"node_modules",
"logs"
],
"error_file":"logs/error.log", // Configure the error log output file address
"out_file":"logs/consoles.log", // Configure the print log output file address
"log_date_format":"YYYY-MM-DD HH:mm:ss", // Configure log date format
"instances":2 // The number of cores occupied by the configuration item , Less than or equal to the total number of cores of the server
}
}
5. Start project : Use pm2 Start project , Switch the command line to the project root folder in advance and execute the following command ( If you do not switch to the project file, you can add the project path to the startup at startup :pm2 start route \index.js):
pm2 start pm2.config.json , If not configured pm2 The configuration file , Then you can go directly through :pm2 index.js or pm2 app.js start-up
6. Save this project , It will restart automatically after startup , Such as :
pm2 save
7. Restart the server , The application can be accessed normally , Of course, we usually use the command line to type commands :pm2 list View the currently started project , The command line path here does not require , Such as :
pm2 list
Tips : This article, pictures and other materials come from the Internet , If there is infringement , Please send an email to :[email protected] Contact the author to delete .
The author : misery
边栏推荐
- The 2022 China low / no code Market Research and model selection evaluation report was released
- Educational Codeforces Round 22 B. The Golden Age
- 淘宝商品详情页API接口、淘宝商品列表API接口,淘宝商品销量API接口,淘宝APP详情API接口,淘宝详情API接口
- What are the common message queues?
- Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
- Five core elements of architecture design
- Taobao commodity details page API interface, Taobao commodity list API interface, Taobao commodity sales API interface, Taobao app details API interface, Taobao details API interface
- 分布式全局ID生成方案
- CVE-2021-3156 漏洞复现笔记
- JVM (19) -- bytecode and class loading (4) -- talk about class loader again
猜你喜欢
论文阅读【Open-book Video Captioning with Retrieve-Copy-Generate Network】
English grammar_ Noun possessive
集群、分布式、微服务的区别和介绍
Preliminary practice of niuke.com (9)
[reading of the paper] a multi branch hybrid transformer network for channel terminal cell segmentation
JSP setting header information export to excel
English语法_名词 - 所有格
Leakage relay jelr-250fg
Flink SQL 实现读写redis,并动态生成Hset key
Introduction to distributed transactions
随机推荐
JVM the truth you need to know
上海字节面试问题及薪资福利
AI face editor makes Lena smile
Message queue: how to deal with message backlog?
Make web content editable
常用消息队列有哪些?
ForkJoin最全详解(从原理设计到使用图解)
JSP setting header information export to excel
Life experience of an update statement
拼多多新店如何获取免费流量,需要从哪些环节去优化,才能有效提升店内免费流量
I didn't know it until I graduated -- the principle of HowNet duplication check and examples of weight reduction
毕业之后才知道的——知网查重原理以及降重举例
Message queuing: how to ensure that messages are not lost
Tablayout modification of customized tab title does not take effect
“多模态”概念
什么是消息队列?
App clear data source code tracking
Jhok-zbg2 leakage relay
Dj-zbs2 leakage relay
淘宝商品详情页API接口、淘宝商品列表API接口,淘宝商品销量API接口,淘宝APP详情API接口,淘宝详情API接口