-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
57 lines (48 loc) · 1.55 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
'use strict';
var util = require('util');
var nconf = require('nconf');
var modulestore = require('edx-modulestore');
// ## //
nconf
.argv()
.file({ file: __dirname + '/config.json' })
.defaults({
environment: process.env.NODE_ENV || 'development',
host: 'localhost',
port: 6500,
url: 'http://localhost:6500',
modulestore: {
mongo: {
uri: '192.168.33.10/edxapp'
},
settings: {
lmsUrl: 'http://localhost:8000',
studioUrl: 'http://localhost:8001',
aboutFields: [
'short_description',
'overview'
]
},
retryInterval: 500
}
});
var app = require('./lib/app');
var connect = function () {
modulestore
.connect(nconf.get('modulestore:mongo:uri'))
.then(function () {
app.listen(nconf.get('port'), nconf.get('host'), function () {
console.error(util.format('edx-modulestore-api: listening on %s:%s', nconf.get('host'), nconf.get('port')));
});
})
.catch(function () {
var interval = nconf.get('modulestore:retryInterval');
console.error(util.format('edx-modulestore-api: could not connect to the database, retrying in %dms', interval));
setTimeout(connect, interval);
});
};
modulestore.on('disconnected', function () {
console.error('edx-modulestore-api: connection lost, exiting');
process.exit(1);
});
connect();