šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

pm2-discord-ts

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

pm2-discord-ts

A Typescript package of pm2-discord

1.2.1
unpublished
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
Ā 
Created
Source

pm2-discord-ts

This is a PM2 Module for sending events from your PM2 process to Discord Webhook.

āš ļø This new version of the module is no longer the same as original style of (pm2-discord). You may still use the old one by installing the version 1.1.2.

Install

$ pm2 install pm2-discord-ts

Setup

pm2 set pm2-discord-ts:url <Webhook URL>

Events

Events are now in array.

The following events can be subscribed to:

  • log - All standard out logs. Default: true
  • error - All error logs. Default: true
  • kill - Event fired when PM2 is killed. Default: false
  • exception - Any exceptions from your processes. Default: false
  • restart - Event fired when a process is restarted. Default: true
  • delete - Event fired when a process is removed from PM2. Default: false
  • stop - Event fired when a process is stopped. Default: true
  • restart overlimit - Event fired when a process is reaches the max amount of times it can restart. Default: true
  • exit - Event fired when a process is exited. Default: false
  • start - Event fired when a process is started. Default: false
  • online - Event fired when a process is online. Default: false
# pm2 set pm2-discord-ts:events log | log,error


$ pm2 set pm2-discord-ts:events <events,events>

Options

  • url - Webhook URL. Required.
  • embeds - Send embeds instead of text. Default: false
  • includeProcessName - Include the process name in the message. Default: true
  • suppressError - Suppress the error if occured. Default: false
  • processTarget (string[] | null) - The process name/id to only emit for. Default: null
  • buffer (bool) - Enable/Disable buffering of messages by timestamp. Messages that occur with the same timestamp (seconds) will be concatenated together and posted as a single message. Default: true
  • bufferDuration (number) - Duration in seconds to aggregate messages. Has no effect if buffer is set to false. Min: 1, Max: 5, Default: 1
  • maxQueue (number) - Number of messages to keep before the queue will be truncated. When the queue exceeds the value, a rate limit message will be sent. Min: 10, Max: 100, Default: 100

Always restart the module after changing any of the options.

# pm2 set pm2-discord-ts:buffer true


$ pm2 set pm2-discord-ts:<key> <value>

$ pm2 restart pm2-discord-ts

Embeds Preview:

  • Log

Embed

  • Error

Error

API

import Log, { Events } from 'pm2-discord-ts';
import ANSI from 'strip-ansi';

const process = new Log({
  events: [Events.Log, Events.Error],
  suppressError: true,
  processTarget: [ 'my-project' ]
});

process.start();

process.on("*", (data, event: Events) => {
  console.log(`Process ${data.process.name} emitted event ${event}`);
});

// Emits on every standard process logs.
process.on("log", (data) => {
  Channel.send({
    content: ANSI(data.data)
  });
})

Methods

  • start(pause?: boolean) - Start listening to the bus.
  • pause(toggle?: boolean) - Pause listening to the bus.

Todo

Done

  • Add API
    • Add PM2 Events

Keywords

pm2-discord

FAQs

Package last updated on 08 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts