<commit_before>#!/bin/bash

ROOT_PATH="${ROOT_PATH}"
INSTANCE_PATH="${INSTANCE_PATH}"
SELF="${'${BASH_SOURCE[0]}'}"

cd "$ROOT_PATH"

# Get the owner of the `run` command. We are using Python since `stat` did not
# present a consistent interface on Linux and OS X.
if [[ $(id -u) == "0" ]]; then
    
    OWNER=$(python -c "import os, pwd; print pwd.getpwuid(os.stat('$SELF').st_uid).pw_name")
    
    # runit.
    if [[ "$(which chpst)" ]]; then
        PRELUDE="chpst -u $OWNER"

    # daemontools.
    elif [[ "$(which setuidgid)" ]]; then
        PRELUDE="setuidgid $OWNER"
    
    fi

fi

. "${ROOT_PATH}/bin/activate"

exec 2>&1
exec $PRELUDE gunicorn \
    -k gevent \
    -b 0.0.0.0:${PORT} \
    -p "$(dirname "$SELF")/pid" \
    ${APP_ENTRYPOINT}
<commit_msg>cd after stat-ing $SELF, so that $SELF exists<commit_after>#!/bin/bash

ROOT_PATH="${ROOT_PATH}"
INSTANCE_PATH="${INSTANCE_PATH}"
SELF="${'${BASH_SOURCE[0]}'}"

# Get the owner of the `run` command. We are using Python since `stat` did not
# present a consistent interface on Linux and OS X.
if [[ $(id -u) == "0" ]]; then
    
    OWNER=$(python -c "import os, pwd; print pwd.getpwuid(os.stat('$SELF').st_uid).pw_name")
    
    # runit.
    if [[ "$(which chpst)" ]]; then
        PRELUDE="chpst -u $OWNER"

    # daemontools.
    elif [[ "$(which setuidgid)" ]]; then
        PRELUDE="setuidgid $OWNER"
    
    fi

fi

. "${ROOT_PATH}/bin/activate"

cd "$ROOT_PATH"

exec 2>&1
exec $PRELUDE gunicorn \
    -k gevent \
    -b 0.0.0.0:${PORT} \
    -p "$(dirname "$SELF")/pid" \
    ${APP_ENTRYPOINT}

{'fraction_non_alphanumeric': 0.1880559085133418, 'fraction_numerical': 0.010165184243964422, 'mean_word_length': 2.9672544080604535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3356765', 'n_tokens_mistral': 641, 'n_tokens_neox': 612, 'n_words': 153}