cluster = require (' cluster '); var http = require (' http '); var os = require (' OS '); var Numcpus = Os.cpus (). Length;if (cluster.ismaster) { //Master: //Let ' s fork as many Workers as you has CPU cores for (var i = 0; i Of course, you can specify any number of worker threads, and the number of threads is not limited to the number of CPU cores, as it is just a child thread running on the CPU.As you can see, to make it work, you need to encapsulate your code in cluster's pr
Node Pm2 configuration and nodepm2 Configuration
System Environment: Centos7
Step 1 install NodeJS
We recommend that you use stable compiled versions. The source code is a little complicated and can be directly used after compilation. The installation is super simple.
The download is successful.
Node-v displays the version number
Npm-v displays the installed version number
Step 2: Install PM2
N
Said NVM had to mention Nodejs's version management NVM and the node app's process manager pm2.Of course, about the two introduction of the article so much, feel free to baidu,bing,google on it.I am here to give myself a label, convenient for future inquiries, two is convenient for some and I like the small white, can speed simple installation and use NVM + PM2.The normal installation sequence should be NVM
cluster = require (' cluster '); var http = require (' http '); var os = require (' OS '); var Numcpus = Os.cpus (). Length;if (cluster.ismaster) { //Master: //Let ' s fork as many Workers as you has CPU cores for (var i = 0; i Of course, you can specify any number of worker threads, and the number of threads is not limited to the number of CPU cores, as it is just a child thread running on the CPU.As you can see, to make it work, you need to encapsulate your code in cluster's pr
TODO: Talking about the basic working principle of PM2To talk about how node. js PM2 Works, you need to first understand the relationship between Satan (Satan) and God.
Satan (Satan), which mainly refers to the fallen angels in the Bible (also known as The Fallen Angels Satan), is the Fallen Angel (fallen Angels) of the Lord who rebelled against God, who was once the angel of God, who later fell into the devil as a result of his arrogant delu
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
Project to Vue.js+layui as the front-end development technology stack, need to have an online environment for project members to view the effect in real time, can not be webpack every time after packaging release to see the effect! Just start with the npm run dev command hot start, but after the shell command window exits, the hot start will fail! Not the computer has been not closed, after the consideration of the way to run the hot-start command, the idea of a good process management tool, is
Ubuntu 12.04 Server can install node JS using Apt-get mode, however, the version after installation is v0.6.12 version, if we want to use a new version of the following configuration:Apt-get Install python-software-propertiesapt-add-repository ppa:chris-lea/node.jsapt-get updateapt-get Install NodejsAfter the installation is complete, you can check the version and use the following command to view:[Email protected]: #node-vv0.10.28Next we need to install PM2
Install First: NPM install-g PM2(Note: Use it to install it first, install it with the root account and the global mode)Installation Complete use: PM2-V view version informationAfter the installation is successful, start the Nodejs project: PM2 start App.js--project nameUsing commandsStartup program: PM2 start Enumerat
Foreverforever can keep the project running when cmd or SSH is disconnected, and can be restarted automatically when the project crashes? Install the NPM install-g forever?forever help manual Forever--help? Use forever to start a project forever start app.js? Use forever to stop the project forever stop app.js? List all projects forever managed by Forever list? Monitoring files in the project, Restart Project when file changes forever-w start App.js II, pm2
": "Forever App.js", "in Forever,package.json configuration Test ":" Supervisor App.js "}, 3, pm2 use it to install it first, with the root account and the global mode installation: NBSP;NPM install-g PM2 use it to start the program (can start directly in the current directory, PM2 start app.js--name uops) [[emailprotected] uops]$
Says node has to mention Nodejs's version management NVM and node app's process manager pm2.Of course, about the two introduction of the article so much, feel free to baidu,bing,google on it.I am here to give myself a label to facilitate future inquiries,Two is convenient for some and I like small white, can speed simple installation and use NVM + PM2.The normal installation sequence should be NVM, Nodejs,
Supervisor is used for development environments.
Forever manages multiple sites, each with a small amount of traffic and no monitoring required.
PM2 website has a large number of visits and requires a complete monitoring interface.
Supervisor Features: Code modification, real-time restartInstallation: CNPM install-g SupervisorStart: Supervisor App.js | | Bin/wwwOverForeverCommon commands:Forever ListForever Start Bin/wwwForever Stop 0 (Fo
PM2 and Forever modules are the most commonly used Nodejs process daemon modules, which are more commonly used and more powerful (providing load). The main principle is PM2 open a main process, and then open the sub-process to run the NODEJS project, the main process to listen to the sub-process, if the child process crashes, PM2 will start it by itself, and can
1. InstallationNPM Install PM2-GD2. StartPM2 start./bin/www3. PM2 Save4, PM2 Startup5. PM2 SaveNote: Several of the above steps have several pits:1, starting from the second step, to enter the root permission operation. The PM2 list is different for different users;2, or the
First, the log1, PM2 log how to view? (The path to the default log after installing PM2 is ~/.pm2/), you can view the log address under a process by PM2 show (name)2, modify the output path of the log, by writing a program to start the configuration file Apps.yml, in which you can set the output address of the log, out
What is the role of App.use in the 1.express framework?The manual reads:App.use ([path], function) Use the given middleware function, with optional mount Path, defaulting to "/".is to introduce a so-called middleware, is actually used to re- hack req and res objects before the actual request to achieve some functions, than if the simplest logger is to add a listener to the end event of the res write a log record, Express uses the middleware provided by Connect,Next (); The program continues in o
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.