-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcron-check.js
More file actions
28 lines (24 loc) · 1016 Bytes
/
cron-check.js
File metadata and controls
28 lines (24 loc) · 1016 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
27
28
// Need to keep operations under 90 seconds to keep things free
const { setCronAlarm } = require("./setCronAlarm");
const { getClient } = require("./util/pgConnect");
const msg = require("./util/sendMessage");
async function check() {
try {
const client2 = await getClient();
const result = await setCronAlarm(client2);
// console.log(result);
if (result.close === false) {
// get it on the next pass
console.log("Shutting down due to time being far off...");
client2.release();
process.exit(); //process.kill(process.pid, "SIGTERM"); // "SIGHUP"
} else {
// it will be past time. wait
console.log("Keeping server awake because it is almost time...");
}
} catch (err) {
console.error("[cron-check] Error starting cron:", err);
msg("When waking up to check the time, we could not properly schedule the reminder. It may or may not work today.");
}
}
check();