-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
37 lines (31 loc) · 1.3 KB
/
server.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
"use strict";
var MONGODB_URL = process.env.MONGODB_URL || 'mongodb://mongo:27017/cloudlog';
var AMQP_URL = process.env.AMQP_URL || 'amqp://rabbitmq';
var HTTP_PORT = process.env.HTTP_PORT || 80;
var LOGIC_LOGFILE = process.env.LOGIC_LOGFILE || '/tmp/server-logic.log';
var OBSTORE_CONFIG = (process.env.OBSTORE_CONFIG && JSON.parse(process.env.OBSTORE_CONFIG)) || {
provider: 'filesystem',
root: '/var/lib/storage',
container: 'cloudlog',
};
var express = require('express');
var morgan = require('morgan');
var Nodalion = require('nodalion');
var nodalionMongo = require('nodalion-mongo');
var nodalionHttp = require('nodalion-http');
var workQueue = require('nodalion-amqp');
require('nodalion-objstore').configure(OBSTORE_CONFIG);
var ns = Nodalion.namespace('/nodalion', ['defaultQueueDomain']);
var cl1 = Nodalion.namespace('/cl1', ['cl1']);
nodalionMongo.db(MONGODB_URL);
var nodalion = new Nodalion(__dirname + '/cedalion/cl1/cl1.cedimg', LOGIC_LOGFILE);
workQueue.connect(nodalion, AMQP_URL, ns.defaultQueueDomain());
var app = express();
app.use(morgan('combined'))
app.use(nodalionHttp.app(nodalion, cl1.cl1()));
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).send('Unknown Error');
});
app.listen(HTTP_PORT);
console.log("Server listening on port " + HTTP_PORT);