You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+63-21Lines changed: 63 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,22 +13,22 @@ pm2 set pm2-slack:slack_url https://slack_url
13
13
14
14
To get the Slack URL, you need to setup an Incoming Webhook. More details on how to set this up can be found here: https://api.slack.com/incoming-webhooks
15
15
16
-
## Configure
16
+
## Events subscription configuration
17
17
18
18
The following events can be subscribed to:
19
19
20
-
- log - All standard out logs from your processes. Default: false
21
-
- error - All error logs from your processes. Default: true
22
-
- kill - Event fired when PM2 is killed. Default: true
23
-
- exception - Any exceptions from your processes. Default: true
24
-
- restart - Event fired when a process is restarted. Default: false
25
-
- reload - Event fired when a cluster is reloaded. Default: false
26
-
- delete - Event fired when a process is removed from PM2. Default: false
27
-
- stop - Event fired when a process is stopped. Default: false
28
-
- restart overlimit - Event fired when a process is reaches the max amount of times it can restart. Default: true
29
-
- exit - Event fired when a process is exited. Default: false
30
-
- start - Event fired when a process is started. Default: false
31
-
- online - Event fired when a process is online. Default: false
20
+
-`log` - All standard out logs from your processes. Default: false
21
+
-`error` - All error logs from your processes. Default: true
22
+
-`kill` - Event fired when PM2 is killed. Default: true
23
+
-`exception` - Any exceptions from your processes. Default: true
24
+
-`restart` - Event fired when a process is restarted. Default: false
25
+
-`reload` - Event fired when a cluster is reloaded. Default: false
26
+
-`delete` - Event fired when a process is removed from PM2. Default: false
27
+
-`stop` - Event fired when a process is stopped. Default: false
28
+
-`restart overlimit` - Event fired when a process is reaches the max amount of times it can restart. Default: true
29
+
-`exit` - Event fired when a process is exited. Default: false
30
+
-`start` - Event fired when a process is started. Default: false
31
+
-`online` - Event fired when a process is online. Default: false
32
32
33
33
You can simply turn these on and off by setting them to true or false using the PM2 set command.
34
34
@@ -41,30 +41,72 @@ pm2 set pm2-slack:error false
41
41
42
42
The following options are available:
43
43
44
-
- username (string) - Set the username used in Slack for posting the message. By default this is the hostname of the server.
45
-
- buffer (bool) - Enable/Disable buffering of messages. Messages that occur in short time will be concatenated together and posted as a single slack message. Default: true
46
-
- buffer_seconds (int) - If buffering is enables, all messages are stored for this interval. If no new messages comes in this interval, buffered message(s) are sended to Slack. If new message comes in this interval, the "timer" will be reseted and buffer starts waiting for the new interval for a new next message. *Note: Puspose is reduction of push notifications on Slack clients.* Default: 2
47
-
- buffer_max_seconds (int) - If time exceed this time, the buffered messages are always sent to Slack, even if new messages are still comming in interval (property `buffer_seconds`). Default: 20
48
-
- queue_max (int) - Maximum number of messages, that can be send in one Slack message (in one bufferring round). When the queue exceeds this maximum, next messages are suppresesed and replaced with message "`Next XX messages have been suppressed.`". Default: 100
-`servername` / `username` (string) - Set the custom username for Slack messages (visible in message headers). Default: server hostname
46
+
-`buffer` (bool) - Enable/Disable buffering of messages. Messages that occur in short time will be concatenated together and posted as a single slack message. Default: true
47
+
-`buffer_seconds` (int) - If buffering is enables, all messages are stored for this interval. If no new messages comes in this interval, buffered message(s) are sended to Slack. If new message comes in this interval, the "timer" will be reseted and buffer starts waiting for the new interval for a new next message. *Note: Puspose is reduction of push notifications on Slack clients.* Default: 2
48
+
-`buffer_max_seconds` (int) - If time exceed this time, the buffered messages are always sent to Slack, even if new messages are still comming in interval (property `buffer_seconds`). Default: 20
49
+
-`queue_max` (int) - Maximum number of messages, that can be send in one Slack message (in one bufferring round). When the queue exceeds this maximum, next messages are suppresesed and replaced with message "*Next XX messages have been suppressed.*". Default: 100
49
50
50
-
Set these options in the same way you subscribe to events.
51
+
Set these options in the same way as subscribing to events.
51
52
52
-
Example: The following configuration options will enable message buffering, and set the buffer duration to 5 seconds. All messages that occur within maximum 5 seconds delay between two neighboring messages will be concatenated into a single slack message.
53
+
54
+
###### Example
55
+
56
+
The following configuration options will enable message buffering, and set the buffer duration to 5 seconds. All messages that occur within maximum 5 seconds delay between two neighboring messages will be concatenated into a single slack message.
53
57
54
58
```
55
-
pm2 set pm2-slack:username pm2-user
59
+
pm2 set pm2-slack:slack_url https://hooks.slack.com/services/123456789/123456789/aaaaaaa
56
60
pm2 set pm2-slack:buffer_seconds 5
57
61
```
58
62
59
63
Note: In this example, the maximum total delay for messages is still 20 seconds (default value for `buffer_max_seconds`). After this time, the buffer will be flushed
60
64
everytime and all messages will be sent.
61
65
66
+
### Process based custom options
67
+
68
+
By default, all options are defined for all processes globally.
69
+
But you can separately define custom options to each PM2 process.
70
+
Use format `pm2-slack:optionName-processName` to process based custom options.
71
+
72
+
If no custom options is defined, the global `pm2-slack:propertyName` will be used.
73
+
74
+
Note: By this way, all custom options can be used for specific process, but events subsciptions configuration is always global only.
75
+
76
+
###### Example
77
+
78
+
We have many processes, includes process `foo` and process `bar`.
79
+
For this two processes will have to define separate Slack URL channel and separate server name.
80
+
Same buffer options will be used for all processed.
81
+
82
+
```
83
+
# Define global options for all processes.
84
+
pm2 set pm2-slack:buffer_seconds 5
85
+
86
+
# Define global options for all processes.
87
+
# (for process `foo` and `bar` the values will be overridden below).
88
+
pm2 set pm2-slack:slack_url https://hooks.slack.com/services/123456789/123456789/aaaaaaa
89
+
pm2 set pm2-slack:servername Orion
90
+
91
+
# Define custom Slack Incomming Webhoook for `foo` process.
92
+
pm2 set pm2-slack:slack_url-foo https://hooks.slack.com/services/123456789/123456789/bbbbbbb
93
+
pm2 set pm2-slack:servername-foo Foo-server
94
+
# Note: The `pm2-slack:buffer_seconds`=5 will be used from global options for this process.
95
+
96
+
# Define custom Slack Incomming Webhoook for `bar` process
97
+
pm2 set pm2-slack:slack_url-bar https://hooks.slack.com/services/123456789/123456789/ccccccc
98
+
pm2 set pm2-slack:servername-foo Bar-server
99
+
# Note: The `pm2-slack:buffer_seconds`=5 will be used from global options for this process.
100
+
```
101
+
62
102
63
103
## Contributing
64
104
65
105
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
66
106
67
107
## Release History
108
+
- 1.1.0 Custom options can be defined to each PM2 process.
109
+
Displaying process ID of cluster mode processes (thanks @abawchen).
0 commit comments