pm2-notify-x2
PM2 process errorError notification to:
[x] DingTalk robots
[x] Enterprise weiChat robots
this project refers to xiaoyiyu’s pm2-notify-x
Install
not published to NPM, please download directly
-
get code
git clone https://github.com/aggic/pm2-notify-x2.git cd pm2-notify-x2
-
install dependencies
npm install
-
install pm2-notify-x2
pm2 install . pm2 list
-
check status is
online
Module ┌────┬───────────────┬──────────────┬───────┬──────────┬──────┬────────┬──────────┐ │ id │ module │ version │ pid │ status │ 0 │ cpu │ mem │ ├────┼───────────────┼──────────────┼───────┼─────────────────────────────────────┤ │ 0 │ pm2-notify-x2 │ 1.0.4 │ 12836 │ online │ 25 │ 1.2% │ 32.6mb │ └────┴───────────────┴──────────────┴───────┴──────────┴──────┴────────┴──────────┘
-
set pm2-notify-x2 config
# send error msg to dingTalk / weiChat / dingTalk&weiChat pm2 set pm2-notify-x2:sendTo dingTalk,weiChat # multiple dingTalk robot secrets or keys, use "," to split, like xxxxxxx1,xxxxxxx1 # dingTalkBotSecrets is dingTalk robot signature key pm2 set pm2-notify-x2:dingTalkBotSecrets xxxxxx # dingTalkBotKeys is dingTalk robot hook url access_token pm2 set pm2-notify-x2:dingTalkBotKeys xxxxxx # multiple weiChat robot secrets or keys, use "," to split, like xxxxxxx1,xxxxxxx1 pm2 set pm2-notify-x2:weiChatBotKeys xxxxxx # set alarm throttle (unit: ms), default is 5000ms = 5s # The same error will not be sent to the robot repeatedly in unit time pm2 set pm2-notify-x2:throttleTime 5000
Tips:
Testing
- create a new file
throw.js
throw new Error(`test the error`);
- start throw.js with pm2
pm2 start throw.js
- like this