<commit_before>#!/bin/sh

### BEGIN INIT INFO
# Provides:          <%= @service_name %>
# Required-Start:    $syslog $remote_fs
# Required-Stop:     $syslog $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: New Relic <%= @plugin_name %> Plugin
# Description:       Controls the New Relic <%= @plugin_name %> Plugin
### END INIT INFO

DESC="New Relic <%= @plugin_name %> Plugin Daemon"
NAME=<%= @service_name %>
VERSION=<%= @version %>
DAEMON=<%= @daemon %>
DAEMONDIR=<%= @daemon_dir %>
PIDFILE=/var/run/$NAME.pid

get_pid() {
  cat "$PIDFILE"
}

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

start() {
  if is_running; then
    echo "Already Started $NAME"
  else
    echo "Starting $NAME"
    cd $DAEMONDIR
    su <%= @user %> -c "<%= @run_command %> $DAEMON >> $DAEMONDIR/daemon.log 2>&1 &"
    echo "$!" > $PIDFILE
  fi
}

status() {
  if is_running; then
    echo "$NAME $VERSION is running"
  else
    echo "$NAME $VERSION is stopped"
    exit 1
  fi
}

stop() {
  if is_running; then
    echo "Stopping $NAME"
    kill `get_pid`
  else
    echo "$NAME is not running"
  fi
}
<commit_msg>Write pid to pidfile as user Pidfile was created blank because $! was not available outside of su; prevented service from stopping correctly.<commit_after>#!/bin/sh

### BEGIN INIT INFO
# Provides:          <%= @service_name %>
# Required-Start:    $syslog $remote_fs
# Required-Stop:     $syslog $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: New Relic <%= @plugin_name %> Plugin
# Description:       Controls the New Relic <%= @plugin_name %> Plugin
### END INIT INFO

DESC="New Relic <%= @plugin_name %> Plugin Daemon"
NAME=<%= @service_name %>
VERSION=<%= @version %>
DAEMON=<%= @daemon %>
DAEMONDIR=<%= @daemon_dir %>
PIDFILE=/var/run/$NAME.pid

get_pid() {
  cat "$PIDFILE"
}

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

start() {
  if is_running; then
    echo "Already Started $NAME"
  else
    echo "Starting $NAME"
    cd $DAEMONDIR
    touch $PIDFILE ; chown <%= @user %> $PIDFILE
    su <%= @user %> -c "<%= @run_command %> $DAEMON >> $DAEMONDIR/daemon.log 2>&1 & echo \$! > $PIDFILE"
  fi
}

status() {
  if is_running; then
    echo "$NAME $VERSION is running"
  else
    echo "$NAME $VERSION is stopped"
    exit 1
  fi
}

stop() {
  if is_running; then
    echo "Stopping $NAME"
    kill `get_pid`
  else
    echo "$NAME is not running"
  fi
}

{'fraction_non_alphanumeric': 0.15861513687600645, 'fraction_numerical': 0.00966183574879227, 'mean_word_length': 3.1624790619765495, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 36, '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': '3672017', 'n_tokens_mistral': 992, 'n_tokens_neox': 897, 'n_words': 262}