1. How to run command in backend?
$ nohup npm start &
or
$ npm start &
$ disown
参考 https://unix.stackexchange.com/questions/3886/difference-between-nohup-disown-and
2. pm2 (好好看看教程 https://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/)
Install - https://pm2.keymetrics.io/
log位置 ~/.pm2/logs,查看xxx-error.log或者xxx-out.log
// 启动和重启
pm2 start --name pinpoint-backend ./dist/main.js
pm2 restart pinpoint-backend
// 列出任务
pm2 list
// 日志分片
pm2 install pm2-logrotate
pm2 set pm2-logrotate:max_size 50M
pm2 set pm2-logrotate:max_size YYYY-MM-DD
pm2 set pm2-logrotate:compress true
pm2 set pm2-logrotate:rotateInterval '0 0 * * *'
pm2 set pm2-logrotate:retain 30
pm2 restart all
3. node 内存问题 JavaScript heap out of memory
// https://futurestud.io/tutorials/pm2-how-to-start-your-app-with-node-js-v8-arguments
// https://futurestud.io/tutorials/pm2-start-node-js-app-with-increased-memory-limit-from-json-configuration#:~:text=js%20file%20located%20within%20the,memory%20limit%20of%208%20GB
// max-old-space-size OR max_old_space_size, I don't know.
pm2 start --node-args="--max_old_space_size=4096" --name pinpoint-backend ./dist/main.js