PM2发送Node服务报错信息到钉钉及企业微信

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

  1. get code

    git clone https://github.com/aggic/pm2-notify-x2.git
    cd pm2-notify-x2
    
  2. install dependencies

    npm install
    
  3. install pm2-notify-x2

    pm2 install .
    pm2 list
    
  4. check status is online

    Module
    ┌────┬───────────────┬──────────────┬───────┬──────────┬──────┬────────┬──────────┐
    │ id │ module        │ version      │ pid   │ status   │ 0    │ cpu    │ mem      │
    ├────┼───────────────┼──────────────┼───────┼─────────────────────────────────────┤
    │ 0  │ pm2-notify-x2 │ 1.0.4        │ 12836 │ online   │ 251.2%   │ 32.6mb   │
    └────┴───────────────┴──────────────┴───────┴──────────┴──────┴────────┴──────────┘
    
  5. 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

  1. create a new file throw.js
    throw new Error(`test the error`);
    
  2. start throw.js with pm2
    pm2 start throw.js
    
  3. like this
    在这里插入图片描述
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值