<commit_before>#!/bin/bash

set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables

# Setup env vars and folders for the storm-nimbus_ctl script
source /var/vcap/jobs/storm-nimbus/helpers/ctl_setup.sh 'storm-nimbus'

mkdir -p $LOG_DIR
mkdir -p $RUN_DIR
mkdir -p $ZOOKEEPER_DIR
mkdir -p $STORM_LOG_DIR

# Set the hostname
hostname <%= index %>.<%= name %>.<%= spec.networks.methods(false).grep(/[^=]$/).first.to_s %>.<%= spec.deployment %>.<%= spec.dns_domain_name %>

case $1 in

  start)
    pid_guard $PIDFILE $JOB_NAME

    chown --recursive vcap:vcap $STORM_HOME
    chown --recursive vcap:vcap $LOG_DIR
    chown --recursive vcap:vcap $ZOOKEEPER_DIR
    chown --recursive vcap:vcap $STORM_LOG_DIR


    if [ ! -d "$STORM_USER_CONFIG_DIR" ]; then

        mkdir -p $STORM_USER_CONFIG_DIR
        ln -sf /var/vcap/jobs/$JOB_NAME/conf/storm.yaml $STORM_USER_CONFIG_DIR/storm.yaml
        chown --recursive vcap:vcap $STORM_USER_CONFIG_DIR
    fi

    exec chpst -u vcap:vcap $STORM_HOME/bin/storm nimbus \
         1>>$LOG_DIR/$JOB_NAME.stdout.log \
         2>>$LOG_DIR/$JOB_NAME.stderr.log &



    # store pid in $PIDFILE
    echo $! > $PIDFILE
    ;;

  stop)
    #kill `cat $PIDFILE`

    if [ -f $PIDFILE ]; then
      TARGET_PID=`cat $PIDFILE`
      if kill -0 $TARGET_PID > /dev/null 2>&1; then
        kill $TARGET_PID
        if kill -0 $TARGET_PID > /dev/null 2>&1; then
          echo "$JOB_NAME did not stop gracefully: killing with kill -9"
          kill -9 $TARGET_PID
        fi
      else
        echo no $JOB_NAME to stop
      fi
    else
      echo no $JOB_NAME to stop
    fi<commit_msg>fixes<commit_after>#!/bin/bash

set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables

# Setup env vars and folders for the storm-nimbus_ctl script
source /var/vcap/jobs/storm-nimbus/helpers/ctl_setup.sh 'storm-nimbus'

mkdir -p $LOG_DIR
mkdir -p $RUN_DIR
mkdir -p $ZOOKEEPER_DIR
mkdir -p $STORM_LOG_DIR

# Set the hostname
hostname <%= index %>.<%= name %>.<%= spec.networks.methods(false).grep(/[^=]$/).first.to_s %>.<%= spec.deployment %>.<%= spec.dns_domain_name %>

case $1 in

  start)
    pid_guard $PIDFILE $JOB_NAME

    chown --recursive vcap:vcap $STORM_HOME
    chown --recursive vcap:vcap $LOG_DIR
    chown --recursive vcap:vcap $ZOOKEEPER_DIR
    chown --recursive vcap:vcap $STORM_LOG_DIR


    if [ ! -d "$STORM_USER_CONFIG_DIR" ]; then

        mkdir -p $STORM_USER_CONFIG_DIR
        ln -sf /var/vcap/jobs/$JOB_NAME/conf/storm.yaml $STORM_USER_CONFIG_DIR/storm.yaml
        rm $STORM_HOME/conf/storm.yaml
        ln -sf /var/vcap/jobs/$JOB_NAME/conf/storm.yaml $STORM_HOME/conf/storm.yaml
        chown --recursive vcap:vcap $STORM_USER_CONFIG_DIR
    fi

    exec chpst -u vcap:vcap $STORM_HOME/bin/storm nimbus \
         1>>$LOG_DIR/$JOB_NAME.stdout.log \
         2>>$LOG_DIR/$JOB_NAME.stderr.log &



    # store pid in $PIDFILE
    echo $! > $PIDFILE
    ;;

  stop)
    #kill `cat $PIDFILE`

    if [ -f $PIDFILE ]; then
      TARGET_PID=`cat $PIDFILE`
      if kill -0 $TARGET_PID > /dev/null 2>&1; then
        kill $TARGET_PID
        if kill -0 $TARGET_PID > /dev/null 2>&1; then
          echo "$JOB_NAME did not stop gracefully: killing with kill -9"
          kill -9 $TARGET_PID
        fi
      else
        echo no $JOB_NAME to stop
      fi
    else
      echo no $JOB_NAME to stop
    fi
{'fraction_non_alphanumeric': 0.11800172265288544, 'fraction_numerical': 0.006316393913293138, 'mean_word_length': 2.617860851505711, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 31, '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': '6340558', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1281, 'n_words': 329}