3 /* Configure winston before all else! */
4 const env = require('gitter-web-env');
5 const winston = env.logger;
6 var nconf = env.config;
7 var express = require('express');
8 var http = require('http');
9 var serverStats = require('./utils/server-stats');
10 var onMongoConnect = require('gitter-web-persistence-utils/lib/on-mongo-connect');
11 const installBridge = require('gitter-web-matrix-bridge');
15 var server = http.createServer(app);
17 require('./web/graceful-shutdown').install(server, app);
19 require('./web/express').installApi(app);
21 require('./web/passport').installApi();
23 require('./event-listeners').install();
25 require('./workers').listen();
27 app.use('/', require('./api/'));
29 if (!process.env.DISABLE_API_ERROR_HANDLER) {
30 app.use(env.middlewares.errorHandler);
33 if (!process.env.DISABLE_API_LISTEN) {
34 onMongoConnect(function() {
35 serverStats('api', server);
37 var port = nconf.get('PORT');
38 server.listen(port, undefined, nconf.get('web:backlog'), function() {
39 winston.info('Listening on ' + port);
44 if (!process.env.DISABLE_MATRIX_BRIDGE) {
45 // Install the Gitter <-> Matrix bridge
49 module.exports = server;