<commit_before>var express = require('express');
var expressValidator = require('express-validator');
var mongoose = require('mongoose');
var connect = require('connect');
var passport = require('passport');

mongoose.connect(process.env.LIBRECMS_MONGO_URI);
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function callback() {
    console.log('Successfully connected to database');
});

// Mongoose Schemata
require('./schemata');

// Passport authentication configuration
require('./auth');

var app = express();
app.configure(function () {
  app.use(expressValidator());
  app.use(express.logger());
  app.use(express.cookieParser());
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.session({ secret: 'keyboard cat' }));
  // Initialize Passport!  Also use passport.session() middleware, to support
  // persistent login sessions (recommended).
  app.use(passport.initialize());<commit_msg>Reconnect on disconnect from MongoDB<commit_after>var express = require('express');
var expressValidator = require('express-validator');
var mongoose = require('mongoose');
var connect = require('connect');
var passport = require('passport');

var db = mongoose.connection;
db.on('error', function(error) {
  console.error('Error in MongoDB connection: ' + error);
  mongoose.disconnect();
});
db.on('connected', function() {
  console.log('Successfully connected to MongoDB');
});
db.on('connecting', function() {
  console.log('Connecting to MongoDB...');
});
db.on('reconnected', function() {
  console.log('Reconnected to MongoDB');
});
db.on('disconnected', function() {
  console.log('Disconnected from MongoDB');
  mongoose.connect(process.env.LIBRECMS_MONGO_URI, {server: {auto_reconnect: true} });
});
mongoose.connect(process.env.LIBRECMS_MONGO_URI, {server: {auto_reconnect: true} });

// Mongoose Schemata
require('./schemata');

// Passport authentication configuration
require('./auth');

var app = express();
app.configure(function () {
  app.use(expressValidator());
  app.use(express.logger());
  app.use(express.cookieParser());
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.session({ secret: 'keyboard cat' }));
  // Initialize Passport!  Also use passport.session() middleware, to support
  // persistent login sessions (recommended).
  app.use(passport.initialize());
{'fraction_non_alphanumeric': 0.171334431630972, 'fraction_numerical': 0.0, 'mean_word_length': 5.94, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2411797', 'n_tokens_mistral': 719, 'n_tokens_neox': 714, 'n_words': 154}