<commit_before>'user strict';

import getLogger from '../libs/winston';
import mongoose from 'mongoose';
import Promise from 'bluebird';

import { 
  dbTestURI, 
  dbURI 
} from '../config/config';

const log = getLogger(module);

mongoose.Promise = Promise;

export let dbTest = {};
export let db = {};

db.connect = () => {
  const mongooseConnection = mongoose.connection;

  mongoose.connect(dbURI);

  mongooseConnection.on('connected', () => {  
    log.info('Mongoose default connection connected to ' + dbURI);
  });

  mongooseConnection.on('error', (err) => {  
    log.error('Mongoose default connection error: ' + err);
  }); 

  mongooseConnection.on('disconnected', () => {
    log.info('Mongoose default connection disconnected'); 
  });

  process.on('SIGINT', () => {  
    mongooseConnection.close( () => { 
      log.info('Mongoose default connection disconnected through app termination'); 
      process.exit(0); 
    }); 
  });
}

dbTest.connect = () => {
  const mongooseConnection = mongoose.connection;

  mongoose.connect(dbTestURI);

  mongooseConnection.on('connected', () => {  
    log.info('Mongoose default connection connected to ' + dbTestURI);
  });

  mongooseConnection.on('error', (err) => {  
    log.error('Mongoose default connection error: ' + err);
  });
}<commit_msg>Crash the app when not connected to db<commit_after>'user strict';

import getLogger from '../libs/winston';
import mongoose from 'mongoose';
import Promise from 'bluebird';

import { 
  dbTestURI, 
  dbURI 
} from '../config/config';

const log = getLogger(module);

mongoose.Promise = Promise;

export let dbTest = {};
export let db = {};

db.connect = () => {
  const mongooseConnection = mongoose.connection;

  let options = {
    server:{
      auto_reconnect:true,
      reconnectTries: 10,
      reconnectInterval: 5000,
    }
  }

  mongoose.connect(dbURI);

  mongooseConnection.on('connected', () => {  
    log.info('Mongoose default connection connected to ' + dbURI);
  });

  mongooseConnection.on('error', (err) => {  
    log.error('Mongoose default connection error: ' + err);
    process.exit(0); 
  }); 

  mongooseConnection.on('disconnected', () => {
    log.info('Mongoose default connection disconnected'); 
    process.exit(0); 
  });

  process.on('SIGINT', () => {  
    mongooseConnection.close( () => { 
      log.info('Mongoose default connection disconnected through app termination'); 
      process.exit(0); 
    }); 
  });
}

dbTest.connect = () => {
  const mongooseConnection = mongoose.connection;

  mongoose.connect(dbTestURI);

  mongooseConnection.on('connected', () => {  
    log.info('Mongoose default connection connected to ' + dbTestURI);
  });

  mongooseConnection.on('error', (err) => {  
    log.error('Mongoose default connection error: ' + err);
  });
}
{'fraction_non_alphanumeric': 0.15477458288959886, 'fraction_numerical': 0.003549875754348598, 'mean_word_length': 3.5821138211382113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '4434611', 'n_tokens_mistral': 900, 'n_tokens_neox': 877, 'n_words': 183}