forked from hasadna/meirim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_emails
More file actions
27 lines (23 loc) · 911 Bytes
/
Copy pathsend_emails
File metadata and controls
27 lines (23 loc) · 911 Bytes
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
#!/usr/bin/env node
const controller = require('../api/controller/cron');
const Log = require('../api/lib/log');
const Email = require('../api/service/email');
const Config = require('../api/lib/config');
const axios = require('axios');
const { runAndReport } = require('../metrics')
async function handleMonitor() {
const sendEmailsHeartbeatUrl = Config.get('uptimeRobot.sendEmailsHeartbeatUrl');
try {
Log.info('reporting to email send monitor on success '+ sendEmailsHeartbeatUrl);
const response = await axios.get(sendEmailsHeartbeatUrl);
Log.info('email send monitor success');
} catch (error) {
Log.error('email send monitor error msg: ' + error.response.body);
}
}
runAndReport({ func: () => {
return Email.init()
.then(() => controller.sendPlanningAlerts())
.then(() => Log.info('sendPlanningAlerts completed'))
.finally(() => process.exit());
}, name: "send_emails"})