<commit_before>var express = require('express'),
    swig = require('swig'),
    locals = require('./node-app/config/locals'),
    swigConfig = require('./node-app/swig/swig-config'),
    middlewareConfig = require('./middleware/middleware-config');

var app = express(),
    port = locals.port;

app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.engine('html', swig.renderFile);

swigConfig(swig);
middlewareConfig(app);

if (locals.SSL.enableSSL) {
  var fs = require('fs');

  var options = {
    key: fs.readFileSync(locals.SSL.key),
    cert: fs.readFileSync(locals.SSL.cert)
  };

  require('https').createServer(options, app).listen(port, function () {
    console.log('server listening on port(SSL enabled) ' + port);
  });
} else {
  require('http').createServer(app).listen(port, function () {
    console.log('server listening on port ' + port);
  });
}
<commit_msg>add error and listening event to server<commit_after>var express = require('express'),
    swig = require('swig'),
    locals = require('./node-app/config/locals'),
    swigConfig = require('./node-app/swig/swig-config'),
    middlewareConfig = require('./middleware/middleware-config');

var app = express(),
    port = locals.port;

app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.engine('html', swig.renderFile);

swigConfig(swig);
middlewareConfig(app);

if (locals.SSL.enableSSL) {
  var fs = require('fs');

  var options = {
    key: fs.readFileSync(locals.SSL.key),
    cert: fs.readFileSync(locals.SSL.cert)
  };

  server = require('https').createServer(options, app).listen(port);
} else {
  server = require('http').createServer(app).listen(port);
}

if (server !== null) {
  server.on('error', onError);
  server.on('listening', onListening);
}

function onError(error) {
  if (error.syscall !== 'listen') {
    loggers.errLogger.error('server internal error', error);
    throw error;
  }

  switch (error.code) {
    case 'EACCES':
      console.error('Port ' + port + ' requires elevated privileges');
      process.exit(1);
      break;
    case 'EADDRINUSE':
      console.error('Port ' + port + ' is already in use');
      process.exit(1);
      break;
    default:
      loggers.errLogger.error('server internal error', error);
      throw error;
  }
}

function onListening() {
  console.log('Server listening on port'
      + (locals.SSL.enableSSL ? '(SSL enabled) ' : ' ') + port);
}

{'fraction_non_alphanumeric': 0.1775317753177532, 'fraction_numerical': 0.0008200082000820008, 'mean_word_length': 3.822134387351779, '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': '24737', 'n_tokens_mistral': 800, 'n_tokens_neox': 792, 'n_words': 159}