forked from meatspaces/meatspace-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
36 lines (28 loc) · 999 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
35
36
'use strict';
var zmq = require('zmq');
var express = require('express');
var configurations = module.exports;
var app = express();
var server = require('http').createServer(app);
var nconf = require('nconf');
var settings = require('./settings')(app, configurations, express);
nconf.argv().env().file({ file: 'local.json' });
// set up meatcounter publisher and connect
// to endpoints
var meatcounter_addrs = nconf.get('meatcounter_addrs');
var zio = zmq.socket('pub');
for (var i = 0; i < meatcounter_addrs.length; i ++) {
zio.connect(meatcounter_addrs[i]);
}
var topic_in = nconf.get('meatcounter_inc_topic');
var topic_out = nconf.get('meatcounter_out_topic');
// set up websocket
var io = require('socket.io').listen(server);
io.configure(function () {
io.set('transports', ['websocket']);
io.set('polling duration', 10);
io.set('log level', 1);
});
// routes
require('./routes')(app, nconf, io, zio, topic_in, topic_out);
server.listen(process.env.PORT || nconf.get('port'));