<commit_before>var fs = require('fs');
var config = require('config');
var getStats = require('./stats').getStats;
var logger = require('./logger.js');

var startTime = new Date();
var MINUTE = 60;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;

var version = 1;

fs.readFile(__dirname + '/../package.json', 'utf8', function(err, data) {
    data = JSON.parse(data);
    version = data.version;
});

var isAlive = function(stats) {
    var lastEnd;
    if (stats.processes.waiting > 0) {
        lastEnd = stats.processes.lastEnd;
        if (Date.now() - lastEnd.getTime() > config.process.maxWaitingTime) {
            return false;
        }
    }

    return true;
};

module.exports = function(options) {
    return function (req, res, next) {
        var stats, alive, reportData, displayData;
        if (/^\/status$/.test(req.url)) {
            stats = getStats();
            alive = isAlive(stats);
            reportData = {
                alive: alive,
                version: version,
                stats: stats,
                uptime: Math.floor((Date.now() - startTime.getTime())/1000),
                logTail: logger.tail()
            };
<commit_msg>Added hostname to /status page. closes #26<commit_after>var fs = require('fs');
var config = require('config');
var getStats = require('./stats').getStats;
var logger = require('./logger.js');
var os = require('os');

var startTime = new Date();
var MINUTE = 60;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;

var version = 1;

fs.readFile(__dirname + '/../package.json', 'utf8', function(err, data) {
    data = JSON.parse(data);
    version = data.version;
});

var isAlive = function(stats) {
    var lastEnd;
    if (stats.processes.waiting > 0) {
        lastEnd = stats.processes.lastEnd;
        if (Date.now() - lastEnd.getTime() > config.process.maxWaitingTime) {
            return false;
        }
    }

    return true;
};

module.exports = function(options) {
    return function (req, res, next) {
        var stats, alive, reportData, displayData;
        if (/^\/status$/.test(req.url)) {
            stats = getStats();
            alive = isAlive(stats);
            reportData = {
                alive: alive,
                hostname: os.hostname(),
                version: version,
                stats: stats,
                uptime: Math.floor((Date.now() - startTime.getTime())/1000),
                logTail: logger.tail()
            };

{'fraction_non_alphanumeric': 0.14848236259228875, 'fraction_numerical': 0.011484823625922888, 'mean_word_length': 2.126923076923077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1953163', 'n_tokens_mistral': 777, 'n_tokens_neox': 738, 'n_words': 185}