<commit_before>/*
    ___ usage ___ en_US ___
    usage: node prolific.tcp.bin.js

        -l, --url       <string>        the url port to logs to
        -i, --inherit   <number>        file handles to inherit
        -I, --ipc                       enable Node.js IPC forwarding
            --configuration <string>    base configuration
            --help                      display this message

    ___ $ ___ en_US ___

        log is required:
            the `--log` address and port is a required argument

        port is not an integer:
            the `--log` port must be an integer

    ___ . ___
*/

var pumper = require('prolific.pumper')
var children = require('child_process')
var inherit = require('prolific.inherit')
var ipc = require('prolific.ipc')
var url = require('url')

require('arguable')(module, require('cadence')(function (async, program) {
    program.helpIf(program.command.param.help)

    program.on('SIGTERM', function () {})

    var configuration = program.command.param.configuration || '{}'
    configuration = JSON.parse(configuration)
    configuration.senders || (configuration.senders = [])
    program.command.params.url.forEach(function (location) {
        var parsed = url.parse(location)
        var protocol = parsed.protocol.substring(0, parsed.protocol.length - 1)
        var moduleName =  [ 'prolific.sender', protocol ].join('.')
        configuration.senders.push({ moduleName: moduleName, url: location })
    })
    var senders = configuration.senders.map(function (sender) {
        var Sender = require(sender.moduleName)
        return new Sender(sender)
    })

    var stdio = inherit(program)

    // TODO Add to very end of existing stdio. This would require a command line
    // switch and it would mean that there would be inheritence for certain
    // number `--inherit=4` so that we'd put ourself after the last inherited.
    process.env.PROLIFIC_LOGGING_FD = String(stdio.length - 1)

    var argv = program.argv.slice()
    var loop = async(function () {
        var child = children.spawn(argv.shift(), argv, { stdio: stdio })
        ipc(program.command.param.ipc, process, child)
        child.stdio[stdio.length - 1].write(JSON.stringify(configuration) + '\n')<commit_msg>Deal with a null configuration in Monitor.<commit_after>/*
    ___ usage ___ en_US ___
    usage: node prolific.tcp.bin.js

        -l, --url       <string>        the url port to logs to
        -i, --inherit   <number>        file handles to inherit
        -I, --ipc                       enable Node.js IPC forwarding
            --configuration <string>    base configuration
            --help                      display this message

    ___ $ ___ en_US ___

        log is required:
            the `--log` address and port is a required argument

        port is not an integer:
            the `--log` port must be an integer

    ___ . ___
*/

var pumper = require('prolific.pumper')
var children = require('child_process')
var inherit = require('prolific.inherit')
var ipc = require('prolific.ipc')
var url = require('url')

require('arguable')(module, require('cadence')(function (async, program) {
    program.helpIf(program.command.param.help)

    program.on('SIGTERM', function () {})

    var configuration = program.command.param.configuration || '{}'
    configuration = JSON.parse(configuration) || {}
    configuration.senders || (configuration.senders = [])
    program.command.params.url.forEach(function (location) {
        var parsed = url.parse(location)
        var protocol = parsed.protocol.substring(0, parsed.protocol.length - 1)
        var moduleName =  [ 'prolific.sender', protocol ].join('.')
        configuration.senders.push({ moduleName: moduleName, url: location })
    })
    var senders = configuration.senders.map(function (sender) {
        var Sender = require(sender.moduleName)
        return new Sender(sender)
    })

    var stdio = inherit(program)

    // TODO Add to very end of existing stdio. This would require a command line
    // switch and it would mean that there would be inheritence for certain
    // number `--inherit=4` so that we'd put ourself after the last inherited.
    process.env.PROLIFIC_LOGGING_FD = String(stdio.length - 1)

    var argv = program.argv.slice()
    var loop = async(function () {
        var child = children.spawn(argv.shift(), argv, { stdio: stdio })
        ipc(program.command.param.ipc, process, child)
        child.stdio[stdio.length - 1].write(JSON.stringify(configuration) + '\n')
{'fraction_non_alphanumeric': 0.11395195062816839, 'fraction_numerical': 0.002204099625303064, 'mean_word_length': 2.534267912772586, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7035440', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1247, 'n_words': 367}