-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathsynbiohub.js
More file actions
36 lines (29 loc) · 1014 Bytes
/
synbiohub.js
File metadata and controls
36 lines (29 loc) · 1014 Bytes
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 config = require('./lib/config')
const App = require('./lib/app')
const db = require('./lib/db')
const fs = require('fs')
const jobUtils = require('./lib/jobs/job-utils')
const java = require('./lib/java')
const gitRev = require('./lib/gitRevision')
const theme = require('./lib/theme')
const loggerOverride = require('./lib/loggerOverride')
loggerOverride()
// Log to error so that it shows up in all logfiles
console.error('SynBioHub server is restarting')
if (!fs.existsSync('synbiohub.sqlite') || fs.statSync('synbiohub.sqlite').size === 0) {
db.sequelize.sync({ force: true }).then(startServer)
} else {
db.umzug.up().then(startServer)
}
config.set('revision', gitRev())
async function startServer () {
await java.init()
await theme.setCurrentThemeFromConfig()
await jobUtils.setRunningJobsToQueued()
await jobUtils.resumeAllJobs()
const app = new App()
app.listen(parseInt(config.get('port')))
}
process.on('SIGINT', function () {
java.shutdown().then(() => process.exit())
})