-
Notifications
You must be signed in to change notification settings - Fork 51
/
serve.ts
43 lines (35 loc) · 1.01 KB
/
serve.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
42
43
require("dotenv").config();
import startTradeBot from "./src/main";
import connectMongodb from "./src/services/mongodb";
import redisClient from "./src/services/redis";
// connect mongodb
connectMongodb()
.then(() => {
console.log('MongoDB connected');
// redis
connectRedis();
})
.catch(error => console.log("MongoDB connect failed", error));
// connect redis
const connectRedis = () => {
redisClient.on('connect', function () {
console.log('Redis database connected' + '\n');
// start tradeBot
startTradeBot();
});
redisClient.on('reconnecting', function () {
console.log('Redis client reconnecting');
});
redisClient.on('ready', function () {
console.log('Redis client is ready');
});
redisClient.on('error', function (err) {
console.log('Something went wrong ' + err);
});
redisClient.on('end', function () {
console.log('\nRedis client disconnected');
console.log('Server is going down now...');
process.exit();
});
redisClient.connect();
}