<commit_before>#!/bin/bash

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# chkconfig: 2345 80 20
# description: Summary: Kafka is a high-throughput distributed messaging system designed for persistent messages as the common case. Throughput rather than features are the primary design constraint.  State about what has been consumed is maintained as part of the consumer not the server. Kafka is explicitly distributed. It is assumed that producers, brokers, and consumers are all spread over multiple machines.
# processname: java
# pidfile: /var/run/kafka/kafka-server.pid
### BEGIN INIT INFO
# Provides:          kafka-server
# Required-Start:    $network $local_fs
# Required-Stop:
# Should-Start:      $named
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Kafka is a high-throughput distributed messaging system designed for persistent messages as the common case.
### END INIT INFO

. /lib/lsb/init-functions

# Autodetect JAVA_HOME if not defined
if [ -f /etc/profile.d/java.sh ]; then
        . /etc/profile.d/java.sh
        [ -z "\$JAVA_HOME" ] && echo "JAVA_HOME is not defined" && exit 1
else
        echo "enviroment not properly set up"
        exit 1
fi
if [ -f /etc/profile.d/kafka.sh ] then
	. /etc/profile.d/kafka.sh
fi

STATUS_RUNNING=0
STATUS_DEAD=1
STATUS_DEAD_AND_LOCK=2
STATUS_NOT_RUNNING=3

NAME=kafka-server
DESC="Kafka daemon"

KAFKA_HOME=${KAFKA_HOME-"/usr/lib/kafka"}
KAFKA_CONF=${KAFKA_CONF-"/etc/kafka/conf"}
KAFKA_RUN_DIR=${KAFKA_RUN-"/var/run/kafka"}
KAFKA_SHUTDOWN_TIMEOUT=${KAFKA_SHUTDOWN_TIMEOUT-10}
KAFKA_START_TIMEOUT=${KAFKA_START_TIMEOUT-10}
KAFKA_USER=${KAFKA_USER-"kafka"}

PID_FILE=$KAFKA_RUN_DIR/kafka-server.pid"}

[ -d $KAFKA_RUN_DIR ] || install -d -m 0755 -o $KAFKA_USER -g $KAFKA_USER $KAFKA_RUN_DIR

start() {
    checkstatus
    status=$?
    if [ "$status" -eq "$STATUS_NOT_RUNNING" ]; then
    	printf "Starting kafka server..."
	su -s /bin/sh $KAFKA_USER -c "/usr/bin/kafka --start" 
	su -s /bin/sh $KAFKA_USER -c "$KAFKA_HOME/bin/kafka-server-start.sh -daemon $KAFKA_CONF/server.properties"
        for i in `seq $KAFKA_START_TIMEOUT`; do
	    checkstatus
    	    if [ $? -eq $STATUS_RUNNING ]; then
	        ps ax | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $1}' > $PID_FILE && \
        	log_success_msg ""
	    	return 0
 	    fi
	    sleep 1
	done
   fi

   if [ "$status" -eq "$STATUS_RUNNING" ]; then<commit_msg>BUG: Forget deleting old start command<commit_after>#!/bin/bash

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# chkconfig: 2345 80 20
# description: Summary: Kafka is a high-throughput distributed messaging system designed for persistent messages as the common case. Throughput rather than features are the primary design constraint.  State about what has been consumed is maintained as part of the consumer not the server. Kafka is explicitly distributed. It is assumed that producers, brokers, and consumers are all spread over multiple machines.
# processname: java
# pidfile: /var/run/kafka/kafka-server.pid
### BEGIN INIT INFO
# Provides:          kafka-server
# Required-Start:    $network $local_fs
# Required-Stop:
# Should-Start:      $named
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Kafka is a high-throughput distributed messaging system designed for persistent messages as the common case.
### END INIT INFO

. /lib/lsb/init-functions

# Autodetect JAVA_HOME if not defined
if [ -f /etc/profile.d/java.sh ]; then
        . /etc/profile.d/java.sh
        [ -z "\$JAVA_HOME" ] && echo "JAVA_HOME is not defined" && exit 1
else
        echo "enviroment not properly set up"
        exit 1
fi
if [ -f /etc/profile.d/kafka.sh ] then
	. /etc/profile.d/kafka.sh
fi

STATUS_RUNNING=0
STATUS_DEAD=1
STATUS_DEAD_AND_LOCK=2
STATUS_NOT_RUNNING=3

NAME=kafka-server
DESC="Kafka daemon"

KAFKA_HOME=${KAFKA_HOME-"/usr/lib/kafka"}
KAFKA_CONF=${KAFKA_CONF-"/etc/kafka/conf"}
KAFKA_RUN_DIR=${KAFKA_RUN-"/var/run/kafka"}
KAFKA_SHUTDOWN_TIMEOUT=${KAFKA_SHUTDOWN_TIMEOUT-10}
KAFKA_START_TIMEOUT=${KAFKA_START_TIMEOUT-10}
KAFKA_USER=${KAFKA_USER-"kafka"}

PID_FILE=$KAFKA_RUN_DIR/kafka-server.pid"}

[ -d $KAFKA_RUN_DIR ] || install -d -m 0755 -o $KAFKA_USER -g $KAFKA_USER $KAFKA_RUN_DIR

start() {
    checkstatus
    status=$?
    if [ "$status" -eq "$STATUS_NOT_RUNNING" ]; then
    	printf "Starting kafka server..."
	su -s /bin/sh $KAFKA_USER -c "$KAFKA_HOME/bin/kafka-server-start.sh -daemon $KAFKA_CONF/server.properties"
        for i in `seq $KAFKA_START_TIMEOUT`; do
	    checkstatus
    	    if [ $? -eq $STATUS_RUNNING ]; then
	        ps ax | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $1}' > $PID_FILE && \
        	log_success_msg ""
	    	return 0
 	    fi
	    sleep 1
	done
   fi

   if [ "$status" -eq "$STATUS_RUNNING" ]; then
{'fraction_non_alphanumeric': 0.10137592914755654, 'fraction_numerical': 0.011386999841847224, 'mean_word_length': 3.616058394160584, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2266259', 'n_tokens_mistral': 2176, 'n_tokens_neox': 2050, 'n_words': 691}