[Utuntu]-pm2 Usage

1. Install

$ npm install pm2 -g

$ pm2 version #check version

2. Start

$ pm2 start app.js # start by filename

$ pm2 start app.js –name “app_process” # create idname

$ pm2 restart app_process # when reload resources

3. List View

$ pm2 list

$ pm2 show app_process # view in detail

4. Log View

$ pm2 log 0 # 0 is id

$ pm2 flush # logfile delete

5. Stop

$ pm2 stop app_process

6. Delete

$ pm2 delete app_process

$ pm2 kill

7. cluster mode

$ pm2 start app.js -i –name “app_process” # “-i 0” is creating max cpu count

8. Using Json

$pm2 start ecosystem.json

"ecosystem.json"
{
  "apps": [{
    "name": "example",
    "script": "app.js",
    "watch": false,
    "env": {
      "NODE_ENV": "production",
      "API_PORT": 4000
    },
    "exec_mode": "cluster",
    "instances": 0
  }]
}

9. Monitoring

$ pm2 monit

One thought on “[Utuntu]-pm2 Usage”

댓글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다