<commit_before>#!/bin/sh
### BEGIN INIT INFO
# Provides:          consul
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $network $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Consul Service Discovery Platform
# Description:       Consul is a tool for discovering and configuring services
#                    in your infrastructure. It provides several key features:
#                       * Service Discovery
#                       * Health Checking
#                       * Key/Valuye Store
#                       * Multi Datacenter
### END INIT INFO

if [ -f <%= node['consul']['etc_config_dir'] %> ]; then
. <%= node['consul']['etc_config_dir'] %>
fi

export GOMAXPROCS=${GOMAXPROCS}

CMD="<%= @consul_binary %> agent -config-dir <%= @config_dir %>"
NAME="consul"

PIDFILE="/var/run/$NAME.pid"
LOGFILE="/var/log/$NAME.log"

get_pid() {
    cat "$PIDFILE"
}

is_running() {
    [ -f "$PIDFILE" ] && ps `get_pid` > /dev/null 2>&1
}

case "$1" in
    start)
    if is_running; then
        echo "$NAME already running"
    else
        echo "Starting $NAME"
        $CMD >> "$LOGFILE" &
        echo $! > "$PIDFILE"
        if ! is_running; then
            echo "Unable to start $NAME, see $LOGFILE"
            exit 1
        fi
    fi
    ;;
    stop)
    if is_running; then
        echo -n "Stopping $NAME..."
        kill -INT `get_pid`
        for i in {1..10}
        do
            if ! is_running; then
                break
            fi

            echo -n "."
            sleep 1
        done
        echo

        if is_running; then<commit_msg>{1..10} does not work in sh<commit_after>#!/bin/sh
### BEGIN INIT INFO
# Provides:          consul
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $network $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Consul Service Discovery Platform
# Description:       Consul is a tool for discovering and configuring services
#                    in your infrastructure. It provides several key features:
#                       * Service Discovery
#                       * Health Checking
#                       * Key/Valuye Store
#                       * Multi Datacenter
### END INIT INFO

if [ -f <%= node['consul']['etc_config_dir'] %> ]; then
. <%= node['consul']['etc_config_dir'] %>
fi

export GOMAXPROCS=${GOMAXPROCS}

CMD="<%= @consul_binary %> agent -config-dir <%= @config_dir %>"
NAME="consul"

PIDFILE="/var/run/$NAME.pid"
LOGFILE="/var/log/$NAME.log"

get_pid() {
    cat "$PIDFILE"
}

is_running() {
    [ -f "$PIDFILE" ] && ps `get_pid` > /dev/null 2>&1
}

case "$1" in
    start)
    if is_running; then
        echo "$NAME already running"
    else
        echo "Starting $NAME"
        $CMD >> "$LOGFILE" &
        echo $! > "$PIDFILE"
        if ! is_running; then
            echo "Unable to start $NAME, see $LOGFILE"
            exit 1
        fi
    fi
    ;;
    stop)
    if is_running; then
        echo -n "Stopping $NAME..."
        kill -INT `get_pid`
        for i in 1 2 3 4 5 6 7 8 9 10
        do
            if ! is_running; then
                break
            fi

            echo -n "."
            sleep 1
        done
        echo

        if is_running; then
{'fraction_non_alphanumeric': 0.12284417549167928, 'fraction_numerical': 0.012405446293494705, 'mean_word_length': 1.7344913151364765, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3290803', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1011, 'n_words': 305}