forked from danny-avila/LibreChat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect.js
38 lines (33 loc) · 1017 Bytes
/
connect.js
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
const path = require('path');
require('module-alias/register');
const moduleAlias = require('module-alias');
const basePath = path.resolve(__dirname, '..', 'api');
moduleAlias.addAlias('~', basePath);
const connectDb = require('~/lib/db/connectDb');
async function connect() {
/**
* Connect to the database
* - If it takes a while, we'll warn the user
*/
let timeout = setTimeout(() => {
console.orange(
'This is taking a while... You may need to check your connection if this fails.',
);
timeout = setTimeout(() => {
console.orange('Still going... Might as well assume the connection failed...');
timeout = setTimeout(() => {
console.orange('Error incoming in 3... 2... 1...');
}, 13000);
}, 10000);
}, 5000);
// Attempt to connect to the database
try {
console.orange('Warming up the engines...');
await connectDb();
clearTimeout(timeout);
} catch (e) {
console.error(e);
process.exit(1);
}
}
module.exports = connect;