-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·30 lines (24 loc) · 1018 Bytes
/
index.js
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
#!/usr/bin/env node --no-warnings
const config = require("./config");
const Server = require("./server");
const formatter = require("./formatter");
async function processServers(servers) {
const results = {errors: false, servers: {}};
for (let name in servers) {
const server = new Server(name, config, servers[name]);
await server.connect();
const result = await server.backup();
results.servers[name] = result;
if (result.errors) {
results.errors = true;
}
server.close();
}
const formattedResults = await (new formatter()).format(results);
for (let configuration of config.notifications) {
const notificationClass = require("./notifications/" + configuration.type);
const notifier = new notificationClass(configuration);
await notifier.notify(results, formattedResults);
}
}
processServers(config.servers).then(() => process.exit(0), e => console.error(e) && process.exit(1));