<commit_before>#!/bin/sh

# Debugging...
set -x

pid=0

# Replace environment variables in the configuration file first. Since this
# is done at runtime by the container it won't be persisted.
envsubst < repo-connector-template.conf > cfg/repo-connector.conf

JAVA_XMS=${JAVA_XMS:-1024M}
JAVA_XMX=${JAVA_XMX:-3584M}

# This signal handling is based on this blog post:
# https://medium.com/@gchudnov/trapping-signals-in-docker-containers-7a57fdda7d86
sig_handler()
{
    if [ ${pid} -ne 0  ]; then
        kill -SIGTERM "${pid}"
        wait "${pid}"
    fi
    exit 143; # 128 + 15 -- SIGTERM
}

# Setup handlers
# On callback, kill the last background process, which is `tail -f /dev/null` and execute the specified handler
trap "kill ${!}; /opt/repo-connector/stop-connector.sh" HUP INT QUIT TERM

java -Xms${JAVA_XMS} -Xmx${JAVA_XMX} -jar /opt/repo-connector/${CONNECTOR_JAR_PREFIX}.jar -start &

pid="${!}"

# Wait forever, but allow handling signals...
while true; do
    tail -f /dev/null & wait "${!}"
done<commit_msg>Maybe this time it will work properly. :-P<commit_after>#!/bin/sh

# Debugging...
set -x

pid=0

# Replace environment variables in the configuration file first. Since this
# is done at runtime by the container it won't be persisted.
envsubst < repo-connector-template.conf > cfg/repo-connector.conf

JAVA_XMS=${JAVA_XMS:-1024M}
JAVA_XMX=${JAVA_XMX:-3584M}

# This signal handling is based on this blog post:
# https://medium.com/@gchudnov/trapping-signals-in-docker-containers-7a57fdda7d86
sig_handler()
{
    if [ ${pid} -ne 0  ]; then
        /opt/repo-connector/stop-connector.sh
        wait "${pid}"
        exit 143; # 128 + 15 -- SIGTERM
    fi
}

# Setup handlers
trap "sig_handler" HUP INT QUIT TERM

java -Xms${JAVA_XMS} -Xmx${JAVA_XMX} -jar /opt/repo-connector/${CONNECTOR_JAR_PREFIX}.jar -start &

pid="${!}"

# Wait forever, but allow handling signals...
while true; do
    wait "${pid}"
done
{'fraction_non_alphanumeric': 0.138270326255826, 'fraction_numerical': 0.024857586742620404, 'mean_word_length': 3.5673758865248226, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3580248', 'n_tokens_mistral': 739, 'n_tokens_neox': 675, 'n_words': 194}