<commit_before>/**
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License. 
**/

var http = require ('http');	     
var express = require("express");
var mongoose = require("mongoose");
var RedisStore = require('connect-redis')(express); 
var sessionStore = new RedisStore();
var Schema = mongoose.Schema;
var bcrypt = require('bcrypt');
var models = require('./models');
var controllers = require('./controllers');
var config = require('./config.js');
var log = config.getLogger();
var middleware = require('./middleware');
var middlewareHandlers = middleware.attachHandlers(config);
var router = require('./router.js');
var connect = require('connect');
var cookie = require('cookie');
var Session = connect.middleware.session.Session;
var compass = require('node-compass');


log.info("Initializing");


// Makes connection asynchronously.  Mongoose will queue up database
// operations and release them when the connection is complete.
mongoose.connect(config.getConfig().databaseURI, function (err, res) {
  if (err) { 
    log.info ('ERROR connecting to: ' + config.getConfig().databaseURI + '. ' + err);
  } else {
    log.info ('Succeeded connected to: ' + config.getConfig().databaseURI);
  }
});

var shutdown = function(sig) {
  if (typeof sig === "string") {
    log.info(Date(Date.now()) + ': Received ' + sig +
      ' - terminating Node server ...');
    mongoose.connection.close();
    log.info('disconnected from database');
    process.exit(0);
  }
};

process.on('exit', function() {
   log.info("Exit event captured");
   shutdown();
});

['SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 'SIGABRT', 'SIGBUS',
  'SIGFPE', 'SIGUSR1', 'SIGSEGV', 'SIGUSR2', 'SIGPIPE', 'SIGTERM'].forEach(function(element, index, array) {
  process.on(element, function() {
    shutdown(element);
  });
});

var app = express();
app.use(express.limit('3mb'));
app.use(express.static(__dirname + '/../assets'));
app.use(express.compress());
app.use(express.bodyParser());
app.use(compass());
app.set('view engine', 'jade');
app.set('views', __dirname + '/../template');
app.use(express.cookieParser());
app.use(express.favicon(__dirname + '/../assets/img/favicon.ico'));
app.use(express.session({
	key: 'driftwood.sid',
	secret: config.getConfig().secretKey,
	store: sessionStore
}));
<commit_msg>Changed max file size to 4mb<commit_after>/**
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License. 
**/

var http = require ('http');	     
var express = require("express");
var mongoose = require("mongoose");
var RedisStore = require('connect-redis')(express); 
var sessionStore = new RedisStore();
var Schema = mongoose.Schema;
var bcrypt = require('bcrypt');
var models = require('./models');
var controllers = require('./controllers');
var config = require('./config.js');
var log = config.getLogger();
var middleware = require('./middleware');
var middlewareHandlers = middleware.attachHandlers(config);
var router = require('./router.js');
var connect = require('connect');
var cookie = require('cookie');
var Session = connect.middleware.session.Session;
var compass = require('node-compass');


log.info("Initializing");


// Makes connection asynchronously.  Mongoose will queue up database
// operations and release them when the connection is complete.
mongoose.connect(config.getConfig().databaseURI, function (err, res) {
  if (err) { 
    log.info ('ERROR connecting to: ' + config.getConfig().databaseURI + '. ' + err);
  } else {
    log.info ('Succeeded connected to: ' + config.getConfig().databaseURI);
  }
});

var shutdown = function(sig) {
  if (typeof sig === "string") {
    log.info(Date(Date.now()) + ': Received ' + sig +
      ' - terminating Node server ...');
    mongoose.connection.close();
    log.info('disconnected from database');
    process.exit(0);
  }
};

process.on('exit', function() {
   log.info("Exit event captured");
   shutdown();
});

['SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 'SIGABRT', 'SIGBUS',
  'SIGFPE', 'SIGUSR1', 'SIGSEGV', 'SIGUSR2', 'SIGPIPE', 'SIGTERM'].forEach(function(element, index, array) {
  process.on(element, function() {
    shutdown(element);
  });
});

var app = express();
app.use(express.limit('4mb'));
app.use(express.static(__dirname + '/../assets'));
app.use(express.compress());
app.use(express.bodyParser());
app.use(compass());
app.set('view engine', 'jade');
app.set('views', __dirname + '/../template');
app.use(express.cookieParser());
app.use(express.favicon(__dirname + '/../assets/img/favicon.ico'));
app.use(express.session({
	key: 'driftwood.sid',
	secret: config.getConfig().secretKey,
	store: sessionStore
}));

{'fraction_non_alphanumeric': 0.15371818333056064, 'fraction_numerical': 0.002828148394609882, 'mean_word_length': 4.758620689655173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5471705', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1742, 'n_words': 549}