forked from tobilg/marathon-slack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (35 loc) · 1.2 KB
/
index.js
File metadata and controls
43 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"use strict";
// Check if we got the necessary info from the environment, otherwise fail directly!
require("require-environment-variables")(["SLACK_WEBHOOK_URL"]);
// Load event listener
var MarathonEventListener = require("./lib/MarathonEventListener");
// Define options
var options = {
marathonUrl: process.env.MARATHON_URL || "master.mesos",
marathonPort: process.env.MARATHON_PORT || 8080,
marathonProtocol: process.env.MARATHON_PROTOCOL || "http",
slackWebHook: process.env.SLACK_WEBHOOK_URL,
slackChannel: process.env.SLACK_CHANNEL || "#marathon",
logging: {
level: process.env.LOG_LEVEL || "info"
}
};
if (process.env.EVENT_TYPES) {
if (process.env.EVENT_TYPES.indexOf(",") > -1) {
options.eventTypes = process.env.EVENT_TYPES.split(",");
} else {
options.eventTypes = [process.env.EVENT_TYPES];
}
}
// Create event listener
var mel = new MarathonEventListener(options);
// Report connection
mel.on("connected", function (timestamp) {
mel.logger.info("Connected to the Marathon Event Bus!");
});
// Report errors
mel.on("error", function (error) {
mel.logger.error(JSON.stringify(error));
});
// Subscribe to Marathon event bus
mel.subscribe();