PM2 command operation

Source: Internet
Author: User

1, the most commonly used belong to nohup, in fact, is in the background to execute the process, at the end add a & [[email protected] ~]$ nohup node/home/zhoujie/ops/app.js &[1] 31490nohup:ignoring input and appending output to ' nohup.out ' is now started, directly accessible, 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 process in the background to hang up     2, with screen to open a screens, This way can be directly on the screen to see the program run   to the application, such as: Screen-r Ops, starting with NPM start,  exit the background: CTRL + A, then press D, can not be directly ctrl +c, otherwise you exit   This way is not professional, hehe, but convenient to look at the operation of the production environment.  :   "Scripts": {    "Start": "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)   [[email 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  │disab Led│└──────────┴────┴──────┴─────┴────────┴───────────┴────────┴─────────────┴──────────┘ use ' PM2 Info < Id|name> ' to get more details on an app[[email protected] uops]$  look, it shows the success, the program has been silently successful start up, Can monitor the operation of the program in real-time, such as the execution of a pm2 restart, then the above restarted that column becomes 1, can show how long the program has been running, memory size, it is so great!     terminate the program is also very simple: PM2 stop     lists all programs that start 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 ' PM2 info <id|name> ' to get more details on an app  View Startup program details: PM2 describe id  copy code [[email protected] uops]$ pm2 desc 0Describing process with PID 0-name app┌─── ────────────────┬─────────────────────────────────────────┐│status            │online & nbsp                                ││name &NB Sp            │app                     &NBSP ;              ││id                │0   & nbsp                                  ││path     & nbsp        │/home/zhoujie/uops/app.js              ││args   &NB Sp          │                        &N Bsp              ││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         & nbsp    │fork_mode                          /  &nBsp ││node V8 arguments│                            () nbsp          ││watch & reload    │?                          ,         &NB Sp  ││interpreter      │node                     &N Bsp              ││restarts          │1       &NB Sp                              ││unstable Resta Rts│0                                 &N Bsp    ││uptime            │93s               &N Bsp           &NBSp        ││created at        │2015-01-07t09:41:25.672z       &NBSP ;        │└───────────────────┴─────────────────────────────────────────┘[[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, use this command: PM2 monit  can get the process (and the cluster) CPU usage and memory consumption (CTRL +C exit)     Real-time centralized log processing: PM2 logs      powerful API:PM2 web  You want to monitor all processes that are managed by PM2, and also want to monitor the status of machines running these processes,  copy code [[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 &NBSP;│ONLINE│&NB Sp       1│9m    │74.762 MB  │disabled││pm2-http-interface│1  │fork│1878│on line│        0│0s    │15.070 MB  │disabled│└────────────────────┴────┴──────┴─ ─────┴────────┴───────────┴────────┴─────────────┴──────────┘ use ' PM2 info <id|name> ' to get more details About an app copy code launch program by the way in the browser access:http://localhost:9615  wipe, my eyes were bright blind, so cool, even the deployment of the server information and program information are displayed:     This thing on the program to run the Monitoring page development is really helpful, hehe ~~    Well, I admit that I am a little out of control, the front said a little confusion, I would like to re-order the command again:  copy code installation: NPM Install-g PM2 Launcher: PM2 start <app_name|id|all> list process: 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 LOGSAPI:PM2 Web (port: 9615)

PM2 Command Action

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.