PM2 란?
- Process Manager 2
- 이름과 같이 프로세스들을 관리해주는 역할.
설치하기
- npm install -g pm2
명령어 사용
프로세스 리스트
pm2 list
- 시작하기
- 기본
pm2 start app.js
- 파라미터 추가
pm2 start app.js --log-date-format="YYYY-MM-DD HH:mm:ss" -- 3010
- 로그 and 옵션 추가.
pm2 start app.js --log-date-format="YYYY-MM-DD HH:mm:ss" --node-args="--expose-gc"
- 혹시 이름을 변경해서 실행하고 싶을때.
pm2 start app.js --name=hello -f
- 파이썬 실행
- 일반 python 으로 할 때
pm2 start app.py
- 지정하여 실행할때.
pm2 start -x --interpreter /usr/bin/python2.7 jobqueue.py --name 'tourcrawler'
- 정지하기
pm2 stop (name or id)
- 죽이기
pm2 delete (name or id)
- 정보보기
- pm2 show (name or id)
- 저장 및 복구 (컴퓨터가 꺼졌거나 pm2가 죽었을 경우.)
- 저장
pm2 save
- 복구
pm2 resurrect
- 로그보기
pm2 logs (name or id)
--err : 에러로그만 보기
--lines <n> : n줄수 만큼 보기
- 모니터링
pm2 monit
- 모니터링 JSON
pm2 web ( port 9615 접속하여 확인 )
출처: http://jsongsong.tistory.com/8 [장송송]