<commit_before>///////////////////
// Main app file //
///////////////////

'use strict';

var path        = require('path');
var colors      = require('colors');
var express     = require('express');
var bodyParser  = require('body-parser');
var compression = require('compression');
var cluster     = require('cluster');
var config      = require('./app/config.json');
var log         = require('./app/lib/log')(config);
var rest        = require('./app/lib/rest')(config, log);
var models      = require('./app/models')(config);
var app         = express();

require('./app/lib/utils.js');
require('./app/lib/errors.js')(config, log);

var db;

if (cluster.isMaster) {
    log.info('BuckUTT Pay server');

    models(function (db_) {
        db = db_;

        var numCPUs = require('os').cpus().length;
        for (var i = numCPUs - 1; i >= 0; --i) {
            cluster.fork();
        }
        cluster.on('exit', function (worker) {
            console.log('worker ' + worker.process.pid + ' died');
        });
    });
} else {
    // Custom files
    var makeRoutes = require('./app/routes');

    // Server configuration
    var port = config.port;

    // Gunzip compression, if nginx is off
    if (config.debug) {
        app.use(compression({
            threshold: 512
        }));
    }

    // POST data parser
    app.use(bodyParser.urlencoded({ extended: true }));
    app.use(bodyParser.json());

    // Static content (will be nginx)
    app.use(express.static(__dirname + '/app/public'));

    // Router API
    var router = express.Router();
    makeRoutes(router, db, config);
    app.use('/api', router);

    app.use(function (req, res) {
        if (!req.xhr) {
            log.warn('404 on ' + req.originalUrl + ' (XHR : ' + req.xhr + ')');
            res.status(404).sendFile(path.resolve('./app/public/404.html'), {}, function () {
                res.end();
            });
        } else {
            Error.emit(res, 404, '404 - Not Found', req.originalUrl);
        }
    });

    app.listen(port);
    log.info('Listenning on port : ' + config.port + ' from worker ' + cluster.worker.id);
}<commit_msg>Multi-core front-end (reverted from commit d0caac66c18ecd90eefc9a61cecdc48cb79f804a)<commit_after>///////////////////
// Main app file //
///////////////////

'use strict';

var path        = require('path');
var colors      = require('colors');
var express     = require('express');
var bodyParser  = require('body-parser');
var compression = require('compression');
var config      = require('./app/config.json');
var log         = require('./app/lib/log')(config);
var rest        = require('./app/lib/rest')(config, log);
var models      = require('./app/models')(config);
var app         = express();

require('./app/lib/utils.js');
require('./app/lib/errors.js')(config, log);

log.info('BuckUTT Pay server');

models(function (db) {
    // Custom files
    var makeRoutes = require('./app/routes');

    // Server configuration
    var port = config.port;

    // Gunzip compression, if nginx is off
    if (config.debug) {
        app.use(compression({
            threshold: 512
        }));
    }

    // POST data parser
    app.use(bodyParser.urlencoded({ extended: true }));
    app.use(bodyParser.json());

    // Static content (will be nginx)
    app.use(express.static(__dirname + '/app/public'));

    // Router API
    var router = express.Router();
    makeRoutes(router, db, config);
    app.use('/api', router);

    app.use(function (req, res) {
        if (!req.xhr) {
            log.warn('404 on ' + req.originalUrl + ' (XHR : ' + req.xhr + ')');
            res.status(404).sendFile(path.resolve('./app/public/404.html'), {}, function () {
                res.end();
            });
        } else {
            Error.emit(res, 404, '404 - Not Found', req.originalUrl);
        }
    });

    app.listen(port);
    log.info('Listenning on port : ' + config.port);
});
{'fraction_non_alphanumeric': 0.19298245614035087, 'fraction_numerical': 0.01398423595219934, 'mean_word_length': 2.15224358974359, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3035984', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1181, 'n_words': 266}