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

        -c, --configuration <string>    json configuration
            --help                      display this message

    ___ . ___
*/
require('arguable')(module, require('cadence')(function (async, program) {
    // Node.js API.
    var assert = require('assert')

    // Construct a prolific pipeline from a configuration.
    var Pipeline = require('prolific.pipeline')

    // Controlled demolition of objects.
    var Destructible = require('destructible')

    // Consolidate chunks from async and sync streams.
    var Asynchronous = require('prolific.consolidator/asynchronous')

    var Thereafter = require('thereafter')

    var thereafter = new Thereafter

    var destructible = new Destructible('monitor')

    var configuration = JSON.parse(program.env.PROLIFIC_CONFIGURATION)
    var pipeline = new Pipeline(configuration)

    var net = require('net')

    var asynchronous = new Asynchronous(pipeline.processors[0])

    var listener
    program.on('message', listener = function (message) {
        assert(message.module == 'prolific' && message.method == 'chunk')
        asynchronous.consume(message.body)
    })
    destructible.addDestructor('messages', function () {
        program.removeListener('message', listener)
    })

    program.on('shutdown', destructible.destroy.bind(destructible))

    async(function () {
        setImmediate(async()) // allows test to get handle
    }, [function () {
        pipeline.close(async())
    }], function () {
        pipeline.open(async())
    }, function () {
        thereafter.run(function (ready) {
            var socket = new net.Socket({ fd: 3 })
            destructible.addDestructor('socket', socket, 'destroy')
            asynchronous.listen(socket, destructible.monitor(async, 'asynchronous'))
            ready.unlatch()
        })
        thereafter.run(function (ready) {
            program.send({ module: 'prolific', method: 'ready' })
            ready.unlatch()
        })
        destructible.completed(250, async())
    }, function () {
        return 0
    })
}))<commit_msg>Correctly invoke destructible monitor.<commit_after>/*
    ___ usage ___ en_US ___
    usage: node monitor.bin.js

        -c, --configuration <string>    json configuration
            --help                      display this message

    ___ . ___
*/
require('arguable')(module, require('cadence')(function (async, program) {
    // Node.js API.
    var assert = require('assert')

    // Construct a prolific pipeline from a configuration.
    var Pipeline = require('prolific.pipeline')

    // Controlled demolition of objects.
    var Destructible = require('destructible')

    // Consolidate chunks from async and sync streams.
    var Asynchronous = require('prolific.consolidator/asynchronous')

    var Thereafter = require('thereafter')

    var thereafter = new Thereafter

    var destructible = new Destructible('monitor')

    var configuration = JSON.parse(program.env.PROLIFIC_CONFIGURATION)
    var pipeline = new Pipeline(configuration)

    var net = require('net')

    var asynchronous = new Asynchronous(pipeline.processors[0])

    var listener
    program.on('message', listener = function (message) {
        assert(message.module == 'prolific' && message.method == 'chunk')
        asynchronous.consume(message.body)
    })
    destructible.addDestructor('messages', function () {
        program.removeListener('message', listener)
    })

    program.on('shutdown', destructible.destroy.bind(destructible))

    async(function () {
        setImmediate(async()) // allows test to get handle
    }, [function () {
        pipeline.close(async())
    }], function () {
        pipeline.open(async())
    }, function () {
        thereafter.run(function (ready) {
            var socket = new net.Socket({ fd: 3 })
            destructible.addDestructor('socket', socket, 'destroy')
            asynchronous.listen(socket, destructible.monitor('asynchronous'))
            ready.unlatch()
        })
        thereafter.run(function (ready) {
            program.send({ module: 'prolific', method: 'ready' })
            ready.unlatch()
        })
        destructible.completed(250, async())
    }, function () {
        return 0
    })
}))
{'fraction_non_alphanumeric': 0.123725671918443, 'fraction_numerical': 0.0027803521779425394, 'mean_word_length': 2.6584745762711863, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '898154', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1148, 'n_words': 268}