Put cron in a function
This commit is contained in:
parent
91f66571bb
commit
07c080f249
|
@ -79,10 +79,11 @@ app.listen(config.port, () => {
|
|||
sendLogsToDiscord(readyMessage, null);
|
||||
});
|
||||
|
||||
cron.schedule("1 * * * *", async () => {
|
||||
try {
|
||||
const runCron = async () => {
|
||||
const mongoConnection = await MongoClient.connect(config.dbConnectionString, { useUnifiedTopology: true });
|
||||
const db = mongoConnection.db(config.db);
|
||||
cron.schedule("1 * * * *", async () => {
|
||||
try {
|
||||
const alerts = await db.collection('alerts').find({open: true}).toArray();
|
||||
const uniqueMangoGroupPks: string[] = [...new Set(alerts.map(alert => alert.mangoGroupPk))];
|
||||
const mangoGroups:any = await reduceMangoGroups(client, connection, uniqueMangoGroupPks);
|
||||
|
@ -110,3 +111,6 @@ cron.schedule("1 * * * *", async () => {
|
|||
sendLogsToDiscord(null, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
runCron();
|
||||
|
|
Loading…
Reference in New Issue