IT 지식
pm2란
GROWNFRESH
2022. 5. 17. 23:22
서버에서 웹 애플리케이션을 운영할 때 Node 서버를 띄우기 위한..
npm 으로 전역에 pm2 를 설치해 사용한다.
npm install pm2 -g
// 앱 실행
pm2 start app.js
// 실행된 프로세스 목록
pm2 list
// 현재 서버에서 실행되고있는 app이 git의 어떤 소스를 기반으로 실행되어있는지 확인
pm2 show app.js
// 앱 재시작
pm2 restart app.js
// 앱 중단
pm2 stop app.js
// 프로세스 목록에서 제거
pm2 delete app.js
// pm2 데몬 자체를 죽이려면
pm2 kill
// 로그 기록 확인
pm2 logs
pm2 logs app.js
** json 파일을 만들어 해당 설정대로 서버를 실행할 수도 있다.
// ecosystem.json
{
"apps": [{
"name": "example",
"script": "app.js",
"watch": false,
"env": {
"NODE_ENV": "production",
"API_PORT": 4000
},
"exec_mode": "cluster",
"instances": 0
}]
}
참고사이트
https://backback.tistory.com/358
Node - pm2란
출처 : https://blog.outsider.ne.kr/1197 사용법 참고 : http://pm2.keymetrics.io/docs/usage/application-declaration/#switching-environments
backback.tistory.com
**pm2란?)
Node.js 어플리케이션을 쉽게 관리하게 해주는 Process Manager다.
Node.js App 을 cluster mode로 실행 or 메모리가 넘침 or 예기치못한 프로세스 종료 등의 상황에 직면햇을 때, pm2 를 이용하면 간단한 설정만으로 손쉽게 처리가능하다.