<commit_before>#!/usr/bin/env bash
#
# elasticsearch
#
# chkconfig:   - 57 47
# description: elasticsearch
# processname: elasticsearch
# config:      <%= node[:elasticsearch][:conf_path] %>/elasticsearch.yml

# Source networking configuration
if [ -f /etc/sysconfig/network ]; then source /etc/sysconfig/network; fi

# Exit if networking is not up
[ "$NETWORKING" = "no" ] && exit

PIDFILE='<%= node[:elasticsearch][:pid_path] %>/<%= node[:elasticsearch][:node_name].to_s.gsub(/\W/, "_") %>.pid'
ES_INCLUDE='<%= node.elasticsearch[:conf_path] %>/elasticsearch-env.sh'
CHECK_PID_RUNNING=$(ps ax | grep 'java' | grep -e "es-pidfile=$PIDFILE" | sed 's/^\s*\([0-9]*\)\s.*/\1/')

start() {
    if [ -f $PIDFILE ]; then
      echo -e "\033[31;1mPID file found in $PIDFILE, already running?\033[0m"
      return 1
    else
      echo -e "\033[1mStarting elasticsearch...\033[0m"
      su - <%= node[:elasticsearch][:user] %> -m -c "ES_INCLUDE=$ES_INCLUDE /usr/local/bin/elasticsearch -p $PIDFILE"
    fi
    return $?
}

stop() {
    if [[ -f $PIDFILE ]]; then
      echo -n -e "\033[1mStopping elasticsearch...\033[0m"

      # REMOVE PIDFILE AND EXIT IF PROCESS NOT RUNNING
      if [ ! $CHECK_PID_RUNNING ]; then
        echo -e "\033[1mPID file found, but no matching process running?\033[0m"
        echo    "Removing PID file..."
        su <%= node[:elasticsearch][:user] %> -m -c "rm $PIDFILE"
        exit $?
      fi

      # KILL PROCESS
      su <%= node[:elasticsearch][:user] %> -m -c "kill $(cat $PIDFILE)"
      r=$?
      timeout=0
      while [ -f $PIDFILE  ]; do
        echo -n '.'
        (( timeout++ ))
        if [ $timeout -gt '15' ]; then return; fi
        sleep 1
      done; echo<commit_msg>Fixed the init script<commit_after>#!/usr/bin/env bash
#
# elasticsearch
#
# chkconfig:   - 57 47
# description: elasticsearch
# processname: elasticsearch
# config:      <%= node[:elasticsearch][:conf_path] %>/elasticsearch.yml

# Source networking configuration
if [ -f /etc/sysconfig/network ]; then source /etc/sysconfig/network; fi

# Exit if networking is not up
[ "$NETWORKING" = "no" ] && exit

PIDFILE='<%= node[:elasticsearch][:pid_path] %>/<%= node[:elasticsearch][:node_name].to_s.gsub(/\W/, "_") %>.pid'
ES_INCLUDE='<%= node.elasticsearch[:conf_path] %>/elasticsearch-env.sh'
CHECK_PID_RUNNING=$(ps ax | grep 'java' | grep -e "es-pidfile=$PIDFILE" | sed 's/^\s*\([0-9]*\)\s.*/\1/')

start() {
    if [ -f $PIDFILE ]; then
      echo -e "\033[31;1mPID file found in $PIDFILE, already running?\033[0m"
      return 1
    else
      echo -e "\033[1mStarting elasticsearch...\033[0m"
      su - <%= node[:elasticsearch][:user] %> -m -c "ES_INCLUDE=$ES_INCLUDE /usr/local/bin/elasticsearch -p $PIDFILE"
    fi
    return $?
}

stop() {
    if [[ -f $PIDFILE ]]; then
      echo -n -e "\033[1mStopping elasticsearch...\033[0m"

      # REMOVE PIDFILE AND EXIT IF PROCESS NOT RUNNING
      if [ ! $CHECK_PID_RUNNING ]; then
        echo -e "\033[1mPID file found, but no matching process running?\033[0m"
        echo    "Removing PID file..."
        su <%= node[:elasticsearch][:user] %> -m -c "rm $PIDFILE"
        exit 0
      fi

      # KILL PROCESS
      su <%= node[:elasticsearch][:user] %> -m -c "kill $(cat $PIDFILE)"
      r=$?
      timeout=0
      while [ -f $PIDFILE  ]; do
        echo -n '.'
        (( timeout++ ))
        if [ $timeout -gt '15' ]; then return; fi
        sleep 1
      done; echo
{'fraction_non_alphanumeric': 0.17758369723435224, 'fraction_numerical': 0.027074235807860263, 'mean_word_length': 2.7025862068965516, 'pattern_counts': {'":': 0, '<': 17, '<?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': '4999034', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1200, 'n_words': 305}