<commit_before>#!/bin/bash

set -e -u

RUN_DIR=/var/vcap/sys/run/vxlan-policy-agent
LOG_DIR=/var/vcap/sys/log/vxlan-policy-agent
PIDFILE=$RUN_DIR/vxlan-policy-agent.pid

mkdir -p /var/vcap/sys/log/monit
exec 1>> /var/vcap/sys/log/monit/vxlan-policy-agent.out.log
exec 2>> /var/vcap/sys/log/monit/vxlan-policy-agent.err.log


case $1 in

  start)

    set +e
    modprobe br_netfilter
    set -e

    mkdir -p $RUN_DIR
    mkdir -p $LOG_DIR

    echo $$ > $PIDFILE

    exec /var/vcap/packages/vxlan-policy-agent/bin/vxlan-policy-agent \
      -config-file=/var/vcap/jobs/vxlan-policy-agent/config/vxlan-policy-agent.json \
      2> >(tee -a $LOG_DIR/vxlan-policy-agent.stderr.log | logger -p user.error -t vxlan-policy-agent) \
      1> >(tee -a $LOG_DIR/vxlan-policy-agent.stdout.log | logger -t vxlan-policy-agent)
    ;;

  stop)

    pid=$(cat $PIDFILE)

    for i in $(seq 30); do
      echo "sending INT to ${pid}..."
      if kill -INT $pid; then
        sleep 1
      else
        echo "exited"
        exit 0
      fi
    done

    echo "timed out; sending SIGQUIT followed by SIGKILL to ${pid}..."
    if kill -QUIT $pid; then
      sleep 5

      echo "killing ${pid}..."
      kill -9 $pid
    fi

    echo "killed"

    ;;

  *)
    echo "Usage: $0 {start|stop}"

    ;;

esac<commit_msg>[vpa job] Improve monit ctl script<commit_after>#!/bin/bash

set -e -u

RUN_DIR=/var/vcap/sys/run/vxlan-policy-agent
LOG_DIR=/var/vcap/sys/log/vxlan-policy-agent
PIDFILE=$RUN_DIR/vxlan-policy-agent.pid

mkdir -p /var/vcap/sys/log/monit
exec 1>> /var/vcap/sys/log/monit/vxlan-policy-agent.out.log
exec 2>> /var/vcap/sys/log/monit/vxlan-policy-agent.err.log


case $1 in

  start)

    set +e
    modprobe br_netfilter
    set -e

    mkdir -p $RUN_DIR
    mkdir -p $LOG_DIR

    echo $$ > $PIDFILE

    exec /var/vcap/packages/vxlan-policy-agent/bin/vxlan-policy-agent \
      -config-file=/var/vcap/jobs/vxlan-policy-agent/config/vxlan-policy-agent.json \
      2> >(tee -a $LOG_DIR/vxlan-policy-agent.stderr.log | logger -p user.error -t vxlan-policy-agent) \
      1> >(tee -a $LOG_DIR/vxlan-policy-agent.stdout.log | logger -t vxlan-policy-agent)
    ;;

  stop)

    pid=$(cat $PIDFILE)

    for i in $(seq 15); do
      echo "sending INT to ${pid}..."
      if kill -INT $pid; then
        sleep 1
      else
        echo "exited"
        exit 0
      fi
    done

    echo "timed out; sending SIGQUIT followed by SIGKILL to ${pid}..."
    if kill -QUIT $pid; then
      sleep 5

      echo "killing ${pid}..."
      kill -9 $pid || true
      rm  -f $PIDFILE
    fi

    echo "killed"

    ;;

  *)
    echo "Usage: $0 {start|stop}"

    ;;

esac
{'fraction_non_alphanumeric': 0.14851111948737278, 'fraction_numerical': 0.009046362608367886, 'mean_word_length': 2.140828402366864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '3017817', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1022, 'n_words': 232}