PM2 설치(Process Manager 2)
PM2(프로세스 매니저 2)
Node.js 기반의 프로세스 관리자 도구.
애플리케이션(Node.js/python/binary/shell script/etc...)을 관리할 수 있는 도구입니다.
특징
공식 페이지
전제 조건
Node.js
[권장] NVM: https://github.com/bybatkhuu/wiki/blob/main/posts/manuals/installs/nvm.md
설치
# Install PM2 through NPM:
npm install -g pm2
# Install pm2-logrotate to rotate logs for PM2:
pm2 install pm2-logrotate
# Check PM2 is running and check the version:
pm2 ping
pm2 -v
👍 ✨
설치 완료
용법
### Run application:
## Start node.js application in the background:
pm2 start app.js
## Start shell script app with naming "script-app":
pm2 start script.sh -n script-app
## Start the python application and watch for changes:
pm2 start python-app.py --watch
## Start binary file with arguments (--port 8080):
pm2 start binary-file -- --port 8080
## Use ecosystem configuration file:
# Generate a simple ecosystem.config.js file:
pm2 init simple
# Update the ecosystem.config.js file according to your needs:
vi ecosystem.config.js
# Start ecosystem.config.js:
pm2 start ecosystem.config.js
## Or use JSON file and start in the foreground:
pm2 start pm2-process.json --no-daemon
## Or use YAML file and specify log file path:
pm2 start pm2-process.yml --log /path/to/logs
### Check logs:
pm2 logs app-name --lines 50
### Restart application:
pm2 restart app-name
### Shows a list of applications registered into PM2:
pm2 list
### Monitor applications:
pm2 monit
### Stop and delete the application:
pm2 stop app-name
pm2 del app-name
### Generate ecosystem.config.js file:
pm2 ecosystem
## Startup application on system reboot:
pm2 startup
#--------------------------------------------------------------------------------
## Run according to shown command!
# For example:
# [PM2] You have to run this command as root. Execute the following command:
# $ sudo su -c "env PATH=$PATH:/home/user/.nvm/versions/node/v12.20.1/bin pm2 startup <distribution> -u <user> --hp <home-path>"
#--------------------------------------------------------------------------------
pm2 save
### Help:
pm2 --help
PM2 플러스
참조
Reference
이 문제에 관하여(PM2 설치(Process Manager 2)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/bybatkhuu/install-pm2-process-manager-2-4pdn텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)