-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
executable file
·34 lines (25 loc) · 937 Bytes
/
app.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
#!/usr/bin/env node
'use strict';
var constants = require('./backend/constants.js'),
database = require('./backend/database.js'),
fs = require('fs'),
config = require('./backend/config.js'),
diskusage = require('./backend/diskusage.js'),
server = require('./backend/server.js');
function exit(error) {
if (error) console.error(error);
process.exit(error ? 1 : 0);
}
database.init();
config.init(process.env.CLOUDRON ? '/app/data/config.json' : 'config.json');
// ensure data directory or crash
fs.mkdirSync(constants.DATA_ROOT, { recursive: true });
// we shall crash if this fails
diskusage.calculate();
// currently just update this every hour to put less strain on the disk
setInterval(diskusage.calculate, 1000 * 60 * 60);
server.init(function (error) {
if (error) exit(error);
console.log(`Using data folder at: ${constants.DATA_ROOT}`);
console.log('Cubby is up and running.');
});