<commit_before>'use strict';

var express = require('express'),
    http = require('http'),
    path = require('path'),
    bodyParser = require('body-parser'),
    routes = require('./routes'),
    logger = require('./logger'),
    expressDomain = require('express-domaining'),
    expressTracking = require('express-tracking'),
    expressLogging = require('express-logging'),
    enableTerminate = require('server-terminate'),
    config = require('./config');

// Default logging level. It can be overridden by configuration.
logger.setLevel('INFO');
logger.format = logger.formatters.json;

// Operation name (for logging purposes)
var OP = 'is-valid';

var app = express();
app.disable('x-powered-by');
app.use(bodyParser.json());
app.use(expressDomain(logger));
app.use(expressTracking({op: OP}));
app.use(expressLogging(logger));

app.use('/', routes);

http.createServer(app).listen(config.get('port'), function() {
  logger.info('Express server listening on port %d', config.get('port'));
});<commit_msg>adding ordered shutdown<commit_after>'use strict';

var express = require('express'),
    http = require('http'),
    path = require('path'),
    bodyParser = require('body-parser'),
    routes = require('./routes'),
    logger = require('./logger'),
    expressDomain = require('express-domaining'),
    expressTracking = require('express-tracking'),
    expressLogging = require('express-logging'),
    enableTerminate = require('server-terminate'),
    config = require('./config');

// Default logging level. It can be overridden by configuration.
logger.setLevel('INFO');
logger.format = logger.formatters.json;

// Operation name (for logging purposes)
var OP = 'is-valid';

var app = express();
app.disable('x-powered-by');
app.use(bodyParser.json());
app.use(expressDomain(logger));
app.use(expressTracking({op: OP}));
app.use(expressLogging(logger));

app.use('/', routes);

var server = http.createServer(app);
// Allow the server to gracefully finish connections without waiting for
// keep-alive connections that are not being used
enableTerminate(server);
server.listen(config.get('port'), function() {
  logger.info('is-user-valid server listening', server.address());
});

function orderedShutdown() {
  logger.debug('ordered shutdown');
  server.terminate(function onTerminated() {
    process.exit(0);
  });
}

process.on('SIGTERM', orderedShutdown);
process.on('SIGINT', orderedShutdown);
process.on('uncaughtException', function() {
  process.exit(2);
});
{'fraction_non_alphanumeric': 0.17282958199356913, 'fraction_numerical': 0.0008038585209003215, 'mean_word_length': 5.130541871921182, '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': '878154', 'n_tokens_mistral': 712, 'n_tokens_neox': 709, 'n_words': 164}