<commit_before>#!/bin/sh
### BEGIN INIT INFO
# Required-Start:    $remote_fs $network $named
# Required-Stop:     $remote_fs $network $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: <%= @daemon_name %> daemon
### END INIT INFO

NAME=<%= @daemon_name %>
USER=<%= @user %>
PIDFILE=/var/run/$NAME.pid

# Load the VERBOSE setting and other rcS variables
[ -f /lib/init/vars.sh ] && . /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
[ -f /lib/lsb/init-functions ] && . /lib/lsb/init-functions

# Load additional configuration
[ -f <%= @env_path %> ] && . <%= @env_path %>

<%= render 'partials/check_running.erb', variables: {user: @user} -%>

do_start()
{
  <% if @ulimit %>
  ulimit -n <%= @ulimit %>
  <% end %>
  start-stop-daemon --start --quiet --chuid $USER --pidfile $PIDFILE --test --startas $KAFKA_RUN -- $KAFKA_ARGS $KAFKA_CONFIG > /dev/null \
    || return 1

  start-stop-daemon --start --quiet --chuid $USER --pidfile $PIDFILE --make-pidfile --background --exec $KAFKA_RUN -- $KAFKA_ARGS $KAFKA_CONFIG \
    || return 2

  check_running
  RETVAL=$?
  return $RETVAL
}

do_stop()
{
  <% if controlled_shutdown_enabled? %>
  start-stop-daemon --stop --quiet --oknodo --signal=TERM --pidfile "$PIDFILE"
  RETVAL=$?
  while pidofproc "$PIDFILE" "$KAFKA"; do sleep 1; done
  <% else %>
  start-stop-daemon --stop --quiet --oknodo --retry=TERM/<%= @kill_timeout %>/KILL/5 --pidfile "$PIDFILE"
  RETVAL=$?
  <% end %>
  rm -f $PIDFILE
  return $RETVAL
}

case "$1" in
  start)
    log_daemon_msg "Starting" "$NAME"
    do_start
    case "$?" in
      0|1) log_end_msg 0 ;;
      2)   log_end_msg 1 ;;
    esac
    ;;
  stop)
    log_daemon_msg "Stopping" "$NAME"
    do_stop
    case "$?" in
      0|1) log_end_msg 0 ;;
      2)   log_end_msg 1 ;;
    esac
    ;;
  restart)
    $0 stop && sleep 2 && $0 start
    ;;
  status)
    status_of_proc -p $PIDFILE "$KAFKA_RUN" "$NAME" && exit 0 || exit $?
    ;;
  *)
    echo "Usage: $NAME {start|stop|restart|status}" >&2
    exit 3
    ;;
esac

exit $RETVAL
<commit_msg>Update Debian SysV init script for LSB pidofproc behavior<commit_after>#!/bin/sh
### BEGIN INIT INFO
# Required-Start:    $remote_fs $network $named
# Required-Stop:     $remote_fs $network $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: <%= @daemon_name %> daemon
### END INIT INFO

NAME=<%= @daemon_name %>
USER=<%= @user %>
PIDFILE=/var/run/$NAME.pid

# Load the VERBOSE setting and other rcS variables
[ -f /lib/init/vars.sh ] && . /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
[ -f /lib/lsb/init-functions ] && . /lib/lsb/init-functions

# Load additional configuration
[ -f <%= @env_path %> ] && . <%= @env_path %>

<%= render 'partials/check_running.erb', variables: {user: @user} -%>

do_start()
{
  <% if @ulimit %>
  ulimit -n <%= @ulimit %>
  <% end %>
  start-stop-daemon --start --quiet --chuid $USER --pidfile $PIDFILE --test --startas $KAFKA_RUN -- $KAFKA_ARGS $KAFKA_CONFIG > /dev/null \
    || return 1

  start-stop-daemon --start --quiet --chuid $USER --pidfile $PIDFILE --make-pidfile --background --exec $KAFKA_RUN -- $KAFKA_ARGS $KAFKA_CONFIG \
    || return 2

  check_running
  RETVAL=$?
  return $RETVAL
}

do_stop()
{
  <% if controlled_shutdown_enabled? %>
  start-stop-daemon --stop --quiet --oknodo --signal=TERM --pidfile "$PIDFILE"
  RETVAL=$?
  while pidofproc "$NAME"; do sleep 1; done
  <% else %>
  start-stop-daemon --stop --quiet --oknodo --retry=TERM/<%= @kill_timeout %>/KILL/5 --pidfile "$PIDFILE"
  RETVAL=$?
  <% end %>
  rm -f $PIDFILE
  return $RETVAL
}

case "$1" in
  start)
    log_daemon_msg "Starting" "$NAME"
    do_start
    case "$?" in
      0|1) log_end_msg 0 ;;
      2)   log_end_msg 1 ;;
    esac
    ;;
  stop)
    log_daemon_msg "Stopping" "$NAME"
    do_stop
    case "$?" in
      0|1) log_end_msg 0 ;;
      2)   log_end_msg 1 ;;
    esac
    ;;
  restart)
    $0 stop && sleep 2 && $0 start
    ;;
  status)
    status_of_proc -p $PIDFILE "$KAFKA_RUN" "$NAME" && exit 0 || exit $?
    ;;
  *)
    echo "Usage: $NAME {start|stop|restart|status}" >&2
    exit 3
    ;;
esac

exit $RETVAL

{'fraction_non_alphanumeric': 0.17088316467341305, 'fraction_numerical': 0.014719411223551058, 'mean_word_length': 2.775173611111111, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 35, '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': '5879993', 'n_tokens_mistral': 1807, 'n_tokens_neox': 1650, 'n_words': 427}