To run my app on heroku I use pm2, and I configure my Procfile with:
worker: node main.js
Before start my app, I need to configure same modules of pm2 with script
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
So, where put this scripts?
Tried
I try to put in postinstall
script on package.json
....
"scripts": {
"start": "pm2 start ecosystem.json",
"postinstall": "sh post-install.sh"
},
When I loggin into 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
Questions
- My Procfile was not executed? Why?
- Where the best place to put mu postinstall script? Should I create my own buildpack and put here?