-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.ts
41 lines (34 loc) · 1.08 KB
/
app.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
34
35
36
37
38
39
40
41
require("newrelic");
import { CronJob } from "cron";
import { run } from "./lib/bot";
import collective from "./lib/bot.collective";
import mint from "./lib/bot.mint";
import splitshort from "./lib/bot.splitshort";
import { logger } from "./lib/init";
import { updateBalances } from "./lib/balance";
import * as db from "./lib/db";
logger.info("Starting worker ...", { time: new Date() });
const bot = new CronJob("*/10 * * * * *", run);
const botCollective = new CronJob("*/10 * * * * *", collective.run);
const botMint = new CronJob("*/20 * * * * *", mint.run);
const balances = new CronJob("* * * * *", updateBalances);
const botSplitshort = new CronJob("*/20 * * * * *", splitshort.run);
/**
* Meant to check the application connections before starting the job
*
* - Checks the database connectivity
*/
const check = async () => {
const client = await db.getClient();
if (!client.isOpen) {
logger.error("check failed", { db: "no" });
}
balances.start();
// bot.start();
// botCollective.start();
// botMint.start();
botSplitshort.start();
};
(() => {
check();
})();