forked from DemocracyOS/democracyos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (32 loc) · 825 Bytes
/
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
const debug = require('debug')
const config = require('lib/config')
const server = require('lib/server')
const checkNodeVersion = require('lib/check-node-version')
const migrations = require('lib/migrations')
const models = require('lib/models')()
const log = debug('democracyos:root')
// Basic server configuration
const opts = {
port: process.env.PORT || config.publicPort,
protocol: config.protocol,
https: config.https
}
if (module === require.main) {
checkNodeVersion()
.then(models.ready())
.then(migrations.ready())
.then(() => {
server(opts, function (err) {
if (err) {
log(err)
process.exit(1)
return
}
log('DemocracyOS server running...')
})
})
.catch((err) => {
log(err.message)
process.exit(1)
})
}