명령어들
sudo touch pm2.json && sudo chown $USER pm2.json && sudo chmod 755 pm2.json
sudo pm2 start pm2.json
sudo pm2 list
sudo pm2 log 0
sudo pm2 stop 0
sudo pm2 delete 0
sudo pm2 start 0
sudo pm2 restart 0
1. 빌드하지 않고 바로 실행
pm2.json
{
"name" : "react:13000",
"script": "npm",
"args" : "start",
"watch" : true,
"env" : {
"PORT": 13000
},
"log_date_format": "YYYY-MM-DD HH:mm Z",
"exec_mode": "fork"
}
2. 빌드하고 실행
- 빌드:
npm run build
- NOTE : 안됨. (2023-09-14 확인)
pm2.json
{
"name" : "react:4000",
"script": "npm",
"args" : "start",
"watch" : true,
"env": {
"PM2_SERVE_PATH": "./build",
"PM2_SERVE_PORT": 4000,
"PM2_SERVE_SPA" : "true",
"PM2_SERVE_HOMEPAGE": "/index.html"
},
"instances" : "max",
"exec_mode" : "cluster"
}
3. 참고 - npm serve
sudo npm install -g server
sudo serve -s build -l 3456