<commit_before>#!/bin/bash

set -u

function send_nsca {
    # unusual ${var+x} construct explained: http://stackoverflow.com/a/13864829
    if [ -z ${CODE+x} ]; then
        CODE=3
        OUTPUT="UNKNOWN: seed-crawler-wrapper-script exited before seeder returned an exit code"
    fi
    # unusual ${var+x} construct explained: http://stackoverflow.com/a/13864829
    if [ -z ${OUTPUT+x} ]; then
        CODE=3
        OUTPUT="UNKNOWN: seed-crawler-wrapper exited before setting OUTPUT - this should never happen"
    fi
    printf "<%= @ipaddress_eth0 %>\t<%= @seed_service_desc %>\t$CODE\t$OUTPUT\n" | /usr/sbin/send_nsca -H <%= @alert_hostname %> >/dev/null
    exit $?
}
trap send_nsca EXIT

export GOVUK_CRAWLER_AMQP_PASS='<%= @amqp_pass %>'

OUTPUT=`eval "$(rbenv init -)" && rbenv shell 2.6.3 && <%= @seeder_script_path %> <%= @seeder_script_args %>`

logger -p local3.info -t seed-crawler-wrapper "$OUTPUT"

CODE=$?
if [ "$OUTPUT" == "" ]; then
  OUTPUT="Seeder script exited with no output"
fi
# Force everything that isn't OK to be a WARNING
if [ $CODE -gt 0 ]; then
  CODE=1
fi
<commit_msg>Set RBENV_ROOT in the seed-crawler-wrapper<commit_after>#!/bin/bash

set -u

function send_nsca {
    # unusual ${var+x} construct explained: http://stackoverflow.com/a/13864829
    if [ -z ${CODE+x} ]; then
        CODE=3
        OUTPUT="UNKNOWN: seed-crawler-wrapper-script exited before seeder returned an exit code"
    fi
    # unusual ${var+x} construct explained: http://stackoverflow.com/a/13864829
    if [ -z ${OUTPUT+x} ]; then
        CODE=3
        OUTPUT="UNKNOWN: seed-crawler-wrapper exited before setting OUTPUT - this should never happen"
    fi
    printf "<%= @ipaddress_eth0 %>\t<%= @seed_service_desc %>\t$CODE\t$OUTPUT\n" | /usr/sbin/send_nsca -H <%= @alert_hostname %> >/dev/null
    exit $?
}
trap send_nsca EXIT

export GOVUK_CRAWLER_AMQP_PASS='<%= @amqp_pass %>'
export RBENV_ROOT=/usr/lib/rbenv

OUTPUT=`eval "$(rbenv init -)" && rbenv shell 2.6.3 && <%= @seeder_script_path %> <%= @seeder_script_args %>`

logger -p local3.info -t seed-crawler-wrapper "$OUTPUT"

CODE=$?
if [ "$OUTPUT" == "" ]; then
  OUTPUT="Seeder script exited with no output"
fi
# Force everything that isn't OK to be a WARNING
if [ $CODE -gt 0 ]; then
  CODE=1
fi

{'fraction_non_alphanumeric': 0.15255731922398588, 'fraction_numerical': 0.02204585537918871, 'mean_word_length': 3.501984126984127, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '1458998', 'n_tokens_mistral': 889, 'n_tokens_neox': 811, 'n_words': 212}