create function sendNotification
This commit is contained in:
parent
d2843a0013
commit
8714c5b65a
|
|
@ -54,32 +54,44 @@ const sendNotification = async () => {
|
|||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
console.log({ auto1: auto1, auto2: auto2, log: log });
|
||||
let autoStatus =
|
||||
auto1?.includes("succeeded") && auto2?.includes("succeeded")
|
||||
? ":check:"
|
||||
: ":red_circle:";
|
||||
let logStatus = log?.includes("succeeded") ? ":check:" : ":red_circle:";
|
||||
if (process.argv[2] === "interval") {
|
||||
if (log.includes("succeeded") === false) {
|
||||
exec("pm2 restart all", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
return;
|
||||
}
|
||||
|
||||
let time = moment(Date.now()).format("HH:mm - DD/MM");
|
||||
let content =
|
||||
"| |Server| System time| Status \n|---|:---:|:---|:---:\n|1|auto.danielvu.com|**" +
|
||||
time +
|
||||
"**|" +
|
||||
autoStatus +
|
||||
"|\n|2|logs.danielvu.com|**" +
|
||||
time +
|
||||
"**|" +
|
||||
logStatus +
|
||||
"|";
|
||||
let params = {
|
||||
type: "stream",
|
||||
to: "Result test - auto.nswteam.net",
|
||||
topic: "test",
|
||||
content: content,
|
||||
};
|
||||
console.log("RESTART: ", stdout)
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log({ auto1: auto1, auto2: auto2, log: log });
|
||||
let autoStatus =
|
||||
auto1?.includes("succeeded") && auto2?.includes("succeeded")
|
||||
? ":check:"
|
||||
: ":red_circle:";
|
||||
let logStatus = log?.includes("succeeded") ? ":check:" : ":red_circle:";
|
||||
|
||||
await client.messages.send(params);
|
||||
let time = moment(Date.now()).format("HH:mm - DD/MM");
|
||||
let content =
|
||||
"| |Server| System time| Status \n|---|:---:|:---|:---:\n|1|auto.danielvu.com|**" +
|
||||
time +
|
||||
"**|" +
|
||||
autoStatus +
|
||||
"|\n|2|logs.danielvu.com|**" +
|
||||
time +
|
||||
"**|" +
|
||||
logStatus +
|
||||
"|";
|
||||
let params = {
|
||||
type: "stream",
|
||||
to: "Result test - auto.nswteam.net",
|
||||
topic: "test",
|
||||
content: content,
|
||||
};
|
||||
|
||||
await client.messages.send(params);
|
||||
}
|
||||
}, 3000);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
|
|||
Loading…
Reference in New Issue