-
Notifications
You must be signed in to change notification settings - Fork 0
/
startServices.js
47 lines (40 loc) · 1.02 KB
/
startServices.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
39
40
41
42
43
44
45
46
47
var isWin = process.platform === "win32";
const Mongod = require('mongod');
const RedisServer = require('redis-server');
var MONGO_CONFIG_PATH = process.env.MONGO_CONFIG_PATH? process.env.MONGO_CONFIG_PATH : null;
if(process.platform === "win32") {
MONGO_CONFIG_PATH = '.\\mongod-win.conf';
}
else if(process.platform === "darwin"){
MONGO_CONFIG_PATH = './mongod.conf';
}
else {
MONGO_CONFIG_PATH = './mongod-linux.conf';
}
const mongoServer = new Mongod({
conf: MONGO_CONFIG_PATH
});
const redisServer = new RedisServer(6379); //default port
function startMongod(err) {
if (err) {
if(err.toString().indexOf("Address already in use") === -1) {
console.log(err);
return;
}
else {
//pass
}
}
mongoServer.open((err) => {
if(err) {
if(err.toString().indexOf("error number 100") === -1) {
console.log(err);
return;
}
else {
//pass
}
}
});
}
redisServer.open().then(startMongod).catch(startMongod);