-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinit.ts
33 lines (29 loc) · 832 Bytes
/
init.ts
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
import {
sendEmail,
sendPushbullet,
sendSms,
sendTelegram,
} from './actions/index.js';
import { AvailabilityChecker } from './availability-checker.js';
import { availabilityUrl, cronSchedule } from './config.js';
import { logger } from './logger.js';
import { readInputFile } from './read-input-file.js';
export const init = async () => {
if (!availabilityUrl) {
logger.warn('No availabilityUrl configured, exiting');
return;
}
const serversToCheck = await readInputFile();
const availabilityChecker = new AvailabilityChecker({
actions: [sendEmail, sendPushbullet, sendSms, sendTelegram],
logger,
serversToCheck,
url: availabilityUrl,
});
if (cronSchedule) {
availabilityChecker.setupSchedule(cronSchedule);
} else {
// Run once
await availabilityChecker.run();
}
};