Nodejs deployment on the tall-PM2

Source: Internet
Author: User

1, the most commonly used belongs to Nohup, in fact, is in the background to execute the process, the end add A & [[email protected] ~]$ nohup Node/home/zhoujie/ops/app.js &
[1] 31490nohup:ignoring input and appending output to ' nohup.out ' that is, this time the program has been started, direct access to, The standard output of the original program is automatically redirected to the Nohup.out file in the current directory, which plays the role of log. This command can continue to run the process after you exit the account/close the terminal.   Nohup is the meaning of not hanging (no hang up). The general form of the command is: Nohup Command & This is not very reliable appearance, often silently in the background of the process of hanging 2, with screen another open screens, this way can be directly on the screen to see the program run on the application to open a screens, such as: Scre   En-r Ops, start with NPM start, exit the background: CTRL + A, then press D, can not be directly ctrl +c, otherwise quit this way is not professional, hehe, but convenient to see in the production environment operation. This is essentially configured in Forever,package.json: "Scripts": {
"Start": "Forever App.js",
"Test": "Supervisor App.js"
}, 3, PM2 use it to install it first, with the root account and the global mode installation: NPM install-g PM2 Use it to start the program (in the current directory can be started directly, PM2 start app.js--name uops) [[Emai L protected] uops]$ PM2 start app.js
[PM2] Spawning PM2 daemon
[PM2] Success
[PM2] Process App.js launched
┌──────────┬────┬──────┬─────┬────────┬───────────┬────────┬─────────────┬──────────┐
│app name│id│mode│pid│status│restarted│uptime│memory│watching│
├──────────┼────┼──────┼─────┼────────┼───────────┼────────┼─────────────┼──────────┤
│app│0│fork│308│online│0│0s│21.879 mb│disabled│
└──────────┴────┴──────┴─────┴────────┴───────────┴────────┴─────────────┴──────────┘
Use the ' PM2 info <id|name> ' to get more details on an app
[[email protected] uops]$ See, it shows success, the program has been silently successful start, can monitor the operation of the program in real time, such as the implementation of a PM2 restart, then the above restarted that column becomes 1, can show how long the program has been running   , the memory size, it is so great! Terminating the program is also simple: PM2 stop lists all programs launched with PM2: PM2 list [[email protected] uops]$ PM2 list
┌──────────┬────┬──────┬─────┬────────┬───────────┬────────┬─────────────┬──────────┐
│app name│id│mode│pid│status│restarted│uptime│memory│watching│
├──────────┼────┼──────┼─────┼────────┼───────────┼────────┼─────────────┼──────────┤
│app│0│fork│984│online│1│3s│64.141 mb│disabled│
└──────────┴────┴──────┴─────┴────────┴───────────┴────────┴─────────────┴──────────┘
Use the ' PM2 info <id|name> ' to get more details about an app View launcher details: PM2 describe ID
[[email protected] uops]$ PM2 desc 0
Describing process withPID 0-name App
┌───────────────────┬─────────────────────────────────────────┐
│status│online│
│name│app│
│id│0│
│path│/home/zhoujie/uops/app.js│
│args││
│exec cwd│/home/zhoujie/uops│
│error Log path│/home/zhoujie/.pm2/logs/app-error-0.log│
│out Log path│/home/zhoujie/.pm2/logs/app-out-0.log│
│pid path│/home/zhoujie/.pm2/pids/app-0.pid│
│mode│fork_mode│
│node V8 arguments││
│watch & reload│? │
│interpreter│node│
│restarts│1│
│unstable restarts│0│
│uptime│93s│
│created at│2015-01-07t09:41:25.672z│
└───────────────────┴─────────────────────────────────────────┘
[[Email protected] uops]$ It's good enough to see all the running processes and their states through the PM2 List command. But how do you track their resource consumption? Don't worry, with this command: PM2 Monit can get the CPU of the process (and the cluster) so Real-time centralized log processing with rate and memory consumption (CTRL +C exit): PM2 logs

Powerful API:PM2 web you want to monitor all the processes that are managed by PM2, and you want to monitor the state of the machines that are running these processes,[email protected] uops]$ PM2 WebLaunching Web interface on port 9615
[PM2] Process/usr/local/node/lib/node_modules/pm2/lib/httpinterface.js launched
[PM2] Process launched
┌────────────────────┬────┬──────┬──────┬────────┬───────────┬────────┬─────────────┬──────────┐
│app name│id│mode│pid│status│restarted│uptime│memory│watching│
├────────────────────┼────┼──────┼──────┼────────┼───────────┼────────┼─────────────┼──────────┤
│app│0│fork│984│online│1│9m│74.762 mb│disabled│
│pm2-http-interface│1│fork│1878│online│0│0s│15.070 mb│disabled│
└────────────────────┴────┴──────┴──────┴────────┴───────────┴────────┴─────────────┴──────────┘
Use the ' PM2 info <id|name> ' to get much details about the when the app launcher is accessed by the browser: http://localhost:9615 is so cool that it actually puts the deployed server information and The information of the program is displayed,this thing to the program running Monitoring page development is really helpful, hehe ~ ~The entire command is as follows: Installation: NPM install-g PM2
Startup program: PM2 start <app_name|id|all>
Enumerating Processes: PM2 list
Exit Program: PM2 Stop <app_name|id|all>
Restart Application: PM2 restart
Program information: PM2 describe Id|all
Monitoring: PM2 Monit
Real-time Centralized log processing: PM2 logs
API:PM2 Web (port: 9615)

Nodejs deployment on the tall-PM2

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.