要在heroku上运行我的应用,我使用pm2,并将Procfile配置为:
worker: node main.js
在启动我的应用程序之前,我需要使用脚本
配置pm2的相同模块npm i -g pm2
pm2 install pm2-logrotate
pm2 install pm2-slack
pm2 set pm2-slack:slack_url $SLACK_URL
pm2 set pm2-slack:log true
pm2 set pm2-slack:error true
pm2 set pm2-slack:restart true
pm2 set pm2-slack:exist true
pm2 set pm2-slack:start true
pm2 set pm2-slack:online true
pm2 set pm2-slack:stop true
那么,放这个脚本的地方呢?
我尝试在postinstall
package.json
脚本
....
"scripts": {
"start": "pm2 start ecosystem.json",
"postinstall": "sh post-install.sh"
},
当我登录heroku run bash
λ heroku run bash
Running bash on <heroku-server>... up, run.XXX
~ $ pm2 l
-------------
Looking for a complete monitoring and management tool for PM2?
_ _ _ _
| | _____ _ _ _ __ ___ ___| |_ _ __(_) ___ ___ (_) ___
| |/ / _ \ | | | '_ ` _ \ / _ \ __| '__| |/ __/ __| | |/ _ \
| < __/ |_| | | | | | | __/ |_| | | | (__\__ \_| | (_) |
|_|\_\___|\__, |_| |_| |_|\___|\__|_| |_|\___|___(_)_|\___/
|___/
Features
- Real Time Dashboard
- CPU/Memory monitoring
- HTTP monitoring
- Event notification
- Custom value monitoring
- Real Time log display
Checkout
https://keymetrics.io/
-------------
[PM2] Spawning PM2 daemon
[PM2] PM2 Successfully daemonized
┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬────────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
└──────────┴────┴──────┴─────┴────────┴─────────┴────────┴────────┴──────────┘
Use `pm2 show <id|name>` to get more details about an app