<commit_before>var http = require('http'),
    apps = require('../config/apps');

var defaults = {
    port: 80,
    path: '/',
    method: 'HEAD',
    interval: 10*60*1000 // 10 minutes
}

// loop through all configured apps, and setup their interval
for(var i = 0; i < apps.length; i++) {
    (function(host, port, path, method, interval) {
        setInterval(function() {
            knockUp(host, port, path, method);
        }, interval);
    }(generateHerokuUrl(apps[i].host),
      apps[i].port || defaults.port,
      apps[i].path || defaults.path,
      apps[i].method || defaults.method,
      apps[i].interval || defaults.interval));
}

function generateHerokuUrl(host) {
    return (host.indexOf('herokuapp.com') === -1)
        ? host + '.herokuapp.com'
        : host;
}

function knockUp(host, port, path, method) {
    var options = {
        host: host,
        port: port,
        path: path,
        method: method
    };

    var req = http.request(options, function (res) {
        console.log(host + ': request successful');<commit_msg>Added http server to shut heroku up<commit_after>var http = require('http'),
    apps = require('../config/apps');

var defaults = {
    port: 80,
    path: '/',
    method: 'HEAD',
    interval: 10*60*1000 // 10 minutes
}

initialiseHttpServer();
initialiseIntervals();

function initialiseIntervals() {
    for(var i = 0; i < apps.length; i++) {
        (function(host, port, path, method, interval) {
            setInterval(function() {
                knockUp(host, port, path, method);
            }, interval);
        }(generateHerokuUrl(apps[i].host),
          apps[i].port || defaults.port,
          apps[i].path || defaults.path,
          apps[i].method || defaults.method,
          apps[i].interval || defaults.interval));
    }
}

function initialiseHttpServer() {
    // we have to bind to the port Heroku gives us
    // or it thinks we've crashed and kills us
    http.createServer(function (request, response) {
      response.writeHead(200, {"Content-Type": "text/plain"});
      response.end("200 OK\n");
  }).listen(process.env.PORT);
}

function generateHerokuUrl(host) {
    return (host.indexOf('herokuapp.com') === -1)
        ? host + '.herokuapp.com'
        : host;
}

function knockUp(host, port, path, method) {
    var options = {
        host: host,
        port: port,
        path: path,
        method: method
    };

    var req = http.request(options, function (res) {
        console.log(host + ': request successful');
{'fraction_non_alphanumeric': 0.1536323938070663, 'fraction_numerical': 0.013497419610956728, 'mean_word_length': 2.5294117647058822, 'pattern_counts': {'":': 1, '<': 5, '<?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': '7267237', 'n_tokens_mistral': 796, 'n_tokens_neox': 760, 'n_words': 193}