3 var env = require('gitter-web-env');
4 var winston = env.logger;
5 var nconf = env.config;
6 var express = require('express');
7 var bayeux = require('./web/bayeux');
8 var appVersion = require('gitter-app-version');
9 var http = require('http');
10 var shutdown = require('shutdown');
11 var serverStats = require('./utils/server-stats');
12 var onMongoConnect = require('gitter-web-persistence-utils/lib/on-mongo-connect');
14 winston.info('Starting http/ws service');
17 var server = http.createServer(app);
19 require('./web/graceful-shutdown').install(server, app);
21 require('./web/express').installSocket(app);
23 app.get('/', function(req, res) {
24 res.send('Nothing to see here. Move along please. ' + appVersion.getVersion());
27 app.get('/api/private/health_check', require('./api/private/health-check'));
28 app.get('/api/private/health_check/full', require('./api/private/health-check-full'));
30 require('./event-listeners').install();
32 var port = nconf.get('PORT') || nconf.get('ws:port');
34 bayeux.attach(server);
36 onMongoConnect(function() {
38 serverStats('websockets', server);
40 server.listen(port, undefined, nconf.get('ws:backlog'), function() {
41 winston.info('Websockets listening on port ' + port);
45 shutdown.addHandler('websockets', 10, function(callback) {
46 server.close(function() {