<commit_before>// MAIN PROGRAM, start here.

// global libs
var assert = require('assert'),
    fs = require('fs'),
    path = require('path'),
    // ExpressJS and associated middleware
    express = require('express'),
    morgan = require('morgan'),
    bodyParser = require('body-parser'),

    logger = require('./utils/logger'),
    logStream,

    // local libs
    utils = require('./utils/general'),
    githubHookHandler = require('./github-hook'),
    configReader = require('./utils/config-reader'),

    // This path is registered with Github as a webhook URL.
    githubHookPath = '/github-hook',

    // This directory contains all the additional service
    // handlers that will be loaded dynamically and attached
    // to this web server.
    HANDLER_DIR = 'handlers';

// The configReader reads the given file, and merges it with any existing user
// configuration file.
configReader.read(path.join(__dirname, 'conf/config.yaml'), function(err, cfg) {
    if (err) {
        throw (err);
    }

    var host = cfg.host,
        port = cfg.port || 8081,
        baseUrl = 'http://' + host + ':' + port,
        prWebhookUrl = baseUrl + githubHookPath;

    logger = logger.initialize(cfg.logDirectory, cfg.logLevel);
    logger.info('nupic.tools server starting...');
    logger.info('nupic.tools will use the following configuration:');
    logger.debug('nupic.tools configuration:\n', utils.sterilizeConfig(cfg));

    // enable web server logging; pipe those log messages through our logger
    logStream = {
        write: function(message){
            logger.debug(message);
        }
    };
<commit_msg>Local PORT env always overrides.<commit_after>// MAIN PROGRAM, start here.

// global libs
var assert = require('assert'),
    fs = require('fs'),
    path = require('path'),
    // ExpressJS and associated middleware
    express = require('express'),
    morgan = require('morgan'),
    bodyParser = require('body-parser'),

    logger = require('./utils/logger'),
    logStream,

    // local libs
    utils = require('./utils/general'),
    githubHookHandler = require('./github-hook'),
    configReader = require('./utils/config-reader'),

    // This path is registered with Github as a webhook URL.
    githubHookPath = '/github-hook',

    // This directory contains all the additional service
    // handlers that will be loaded dynamically and attached
    // to this web server.
    HANDLER_DIR = 'handlers';

// The configReader reads the given file, and merges it with any existing user
// configuration file.
configReader.read(path.join(__dirname, 'conf/config.yaml'), function(err, cfg) {
    if (err) {
        throw (err);
    }

    var host = cfg.host,
        port = cfg.port || 8081,
        baseUrl = 'http://' + host + ':' + port,
        prWebhookUrl = baseUrl + githubHookPath;

    if (process.env.PORT) {
        // Local env always overrides port.
        port = process.env.PORT;
    }

    logger = logger.initialize(cfg.logDirectory, cfg.logLevel);
    logger.info('nupic.tools server starting...');
    logger.info('nupic.tools will use the following configuration:');
    logger.debug('nupic.tools configuration:\n', utils.sterilizeConfig(cfg));

    // enable web server logging; pipe those log messages through our logger
    logStream = {
        write: function(message){
            logger.debug(message);
        }
    };

{'fraction_non_alphanumeric': 0.13101209796400118, 'fraction_numerical': 0.002360578341693715, 'mean_word_length': 2.8047138047138045, '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': '992498', 'n_tokens_mistral': 965, 'n_tokens_neox': 931, 'n_words': 281}