<commit_before>
# runner that provides some isolation/protection/security.

class DockerRunner

  def run(paas, sandbox, command, max_seconds)
    Rails.logger.warn("DockerRunner")
    # TODO: move this out of katas/ subfolder
    cid_filename = paas.path(sandbox) + 'store.cid'

    `rm -f #{cid_filename}`
    language = sandbox.avatar.kata.language
    cmd = "docker run -u www-data" +
          " -v #{paas.path(sandbox)}:/sandbox:rw" +
          " -v #{paas.path(language)}:#{paas.path(language)}:ro" +
          " -w /sandbox" +
          " --cidfile=\"#{cid_filename}\"" +
          " #{language.image_name} /bin/bash -c \"#{command}\""

    # timeout must go on 'docker run' command and not on
    # the command passed to docker run. This is to ensure
    # the docker run command does not start doing a docker pull
    # from the docker index which could easily take considerably
    # longer than the max_seconds limit.

    Rails.logger.warn("DockerRunner.run " + cmd)

    kill = 9
    `timeout --signal=#{kill} #{max_seconds}s #{cmd}`
    exitstatus = $?.exitstatus
    killed_by_timeout = 128+kill

    cid = `cat #{cid_filename}`
    Rails.logger.warn("cid = #{cid}")<commit_msg>trying docker run with -t<commit_after>
# runner that provides some isolation/protection/security.

class DockerRunner

  def run(paas, sandbox, command, max_seconds)
    Rails.logger.warn("DockerRunner")
    # TODO: move this out of katas/ subfolder
    cid_filename = paas.path(sandbox) + 'store.cid'

    `rm -f #{cid_filename}`
    language = sandbox.avatar.kata.language
    cmd = "docker run -u www-data -t" +
          " -v #{paas.path(sandbox)}:/sandbox:rw" +
          " -v #{paas.path(language)}:#{paas.path(language)}:ro" +
          " -w /sandbox" +
          " --cidfile=\"#{cid_filename}\"" +
          " #{language.image_name} /bin/bash -c \"#{command}\""

    # timeout must go on 'docker run' command and not on
    # the command passed to docker run. This is to ensure
    # the docker run command does not start doing a docker pull
    # from the docker index which could easily take considerably
    # longer than the max_seconds limit.

    Rails.logger.warn("DockerRunner.run " + cmd)

    kill = 9
    raw = `timeout --signal=#{kill} #{max_seconds}s #{cmd}`
    exitstatus = $?.exitstatus
    killed_by_timeout = 128+kill

    Rails.logger.warn("raw = #{raw}")
    cid = `cat #{cid_filename}`
    Rails.logger.warn("cid = #{cid}")
{'fraction_non_alphanumeric': 0.1393543114017164, 'fraction_numerical': 0.0032693093583980384, 'mean_word_length': 2.867298578199052, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2095568', 'n_tokens_mistral': 824, 'n_tokens_neox': 803, 'n_words': 221}