<commit_before>var child_process = require('child_process');
var fs = require('fs');
var util = require('util');

var ContainerBase = require('../../common/container');

// --

function Container() {
    ContainerBase.apply(this, arguments);

    this.dockerProcess = null;
    this.dockerProcessActive = false;
    this.dockerContainerId = null;
}

util.inherits(Container, ContainerBase);

// --

Container.prototype.engineStop = function (callback) {
    if (!this.dockerProcessActive) {
        // this probably died and we don't need to signal it
        callback();

        return;
    }

    this.dockerProcess.on(
        'exit',
        function () {
            callback();
        }
    );

    this.dockerProcess.kill('SIGTERM');
}

Container.prototype.engineStart = function (callback) {
    var that = this;
    var args = [];

    args.push('run');

    var exposedPortMap = this.env.getAllExposedPorts();

    Object.keys(exposedPortMap).forEach(
        function (key) {
            args.push('-p', (exposedPortMap[key].publishAddress ? exposedPortMap[key].publishAddress : '') + ':' + (exposedPortMap[key].publishPort ? exposedPortMap[key].publishPort : '') + ':' + exposedPortMap[key].port + '/' + exposedPortMap[key].protocol);
        }
    );

    var volumeMap = this.env.getAllVolumes();

    Object.keys(volumeMap).forEach(
        function (key) {
            args.push('-v', volumeMap[key] + ':/scs-mnt/' + key);
        }
    );

    this.env.setVariable('SCS_RUN_ID', this.id);

    var env = process.env;
    var nenv = this.env.getAllVariables();

    Object.keys(nenv).forEach(
        function (key) {
            args.push('-e', key);
            env[key] = nenv[key];
        }
    );

    args.push('-cidfile', '/tmp/scs-' + this.id + '.cid');
    args.push('scs-' + this.cimage.get('id.uid'));

    this.logger.verbose(
        'container/run/env',
        JSON.stringify(env)
    );

    this.logger.verbose(
        'container/run/exec',<commit_msg>name the containers for easier referencing<commit_after>var child_process = require('child_process');
var fs = require('fs');
var util = require('util');

var ContainerBase = require('../../common/container');

// --

function Container() {
    ContainerBase.apply(this, arguments);

    this.dockerProcess = null;
    this.dockerProcessActive = false;
    this.dockerContainerId = null;
}

util.inherits(Container, ContainerBase);

// --

Container.prototype.engineStop = function (callback) {
    if (!this.dockerProcessActive) {
        // this probably died and we don't need to signal it
        callback();

        return;
    }

    this.dockerProcess.on(
        'exit',
        function () {
            callback();
        }
    );

    this.dockerProcess.kill('SIGTERM');
}

Container.prototype.engineStart = function (callback) {
    var that = this;
    var args = [];

    args.push('run');

    var exposedPortMap = this.env.getAllExposedPorts();

    Object.keys(exposedPortMap).forEach(
        function (key) {
            args.push('-p', (exposedPortMap[key].publishAddress ? exposedPortMap[key].publishAddress : '') + ':' + (exposedPortMap[key].publishPort ? exposedPortMap[key].publishPort : '') + ':' + exposedPortMap[key].port + '/' + exposedPortMap[key].protocol);
        }
    );

    var volumeMap = this.env.getAllVolumes();

    Object.keys(volumeMap).forEach(
        function (key) {
            args.push('-v', volumeMap[key] + ':/scs-mnt/' + key);
        }
    );

    this.env.setVariable('SCS_RUN_ID', this.id);

    var env = process.env;
    var nenv = this.env.getAllVariables();

    Object.keys(nenv).forEach(
        function (key) {
            args.push('-e', key);
            env[key] = nenv[key];
        }
    );

    args.push('--name', 'scs-' + this.ccontainer.get('name.local') + '--' + this.id);
    args.push('-cidfile', '/tmp/scs-' + this.id + '.cid');
    args.push('scs-' + this.cimage.get('id.uid'));

    this.logger.verbose(
        'container/run/env',
        JSON.stringify(env)
    );

    this.logger.verbose(
        'container/run/exec',
{'fraction_non_alphanumeric': 0.1668702663083313, 'fraction_numerical': 0.0, 'mean_word_length': 2.535405872193437, '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': '3389202', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1262, 'n_words': 216}