summaryrefslogtreecommitdiff
path: root/main.js
blob: 1f26faad88480c31b6bdfeaaab90db996ed47a08 (plain)
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
#! /usr/bin/env node

var path = require('path');
var logging = require('node-logging');
var express = require('express');
var args = require('optimist')
	.usage('Usage: $0 -c configuration [-h]')
	.default('c', './config')
	.describe('c', 'Configuration file')
	.describe('h', 'This help message')
        .argv;

if(args.h) {
	args.showHelp(fn=console.error);
	return;
}

process.on('uncaughtException', function(err) {
	console.error('uncaughtException: ' + (err.stack || err.message || err.toString()));
});

process.chdir(__dirname);

var config = require('./config');
logging.setLevel(config.logLevel || 'info');

var app = express();
app.use(logging.requestLogger);
app.use(express.staticCache());
app.use(express.static(path.join(__dirname, config.Config.rootDir)));
config.Config.app = app;
config.Config.logger = logging;


var model = require('./model_' + config.modelBackend);
model.start(config.Config);

var frontend = require('./frontend');
frontend.setModel(model);
frontend.start(config.Config);