#!/bin/bash -e

JOB_DIR=/var/vcap/jobs/syslog-configurator
PIDFILE=/var/vcap/sys/run/syslog-configurator.pid
declare -a LOG_DIRS=(
  "/var/vcap/sys/log/service-backup"
  "/var/vcap/sys/log/service-metrics"
)

source /var/vcap/packages/redis-common/utils.sh

case $1 in

  start)
    <% if_p("syslog_aggregator.address", "syslog_aggregator.port") do %>

      CONFIG_DIR=$JOB_DIR/config

      if [ ! -d $CONFIG_DIR ]
      then
        echo "$CONFIG_DIR not found"
        exit 1
      fi

      cp $CONFIG_DIR/syslog_forwarder.conf /etc/rsyslog.d/05-syslog_forwarder.conf

      for dir in "${LOG_DIRS[@]}"; do
        mkdir -p $dir
        if [ ! -f $dir/out.log ]; then
          touch $dir/out.log
        fi
      done

      /usr/sbin/service rsyslog restart

    <% end %>

    echo $$ > $PIDFILE

    while true; do exec sleep 10000; done

    ;;

  stop)
    kill_and_wait $PIDFILE 55
    ;;

  *)
    echo "Usage: syslog-configurator_ctl {start|stop}"
    ;;

esac

#!/bin/bash -e

JOB_DIR=/var/vcap/jobs/syslog-configurator
PIDFILE=/var/vcap/sys/run/syslog-configurator.pid
declare -a LOG_DIRS=(
  "/var/vcap/sys/log/service-backup"
  "/var/vcap/sys/log/service-metrics"
)

source /var/vcap/packages/redis-common/utils.sh

case $1 in

  start)
    <% if_p("syslog_aggregator.address", "syslog_aggregator.port") do %>

      CONFIG_DIR=$JOB_DIR/config

      if [ ! -d $CONFIG_DIR ]
      then
        echo "$CONFIG_DIR not found"
        exit 1
      fi

      cp $CONFIG_DIR/syslog_forwarder.conf /etc/rsyslog.d/05-syslog_forwarder.conf

      for dir in "${LOG_DIRS[@]}"; do
        mkdir -p $dir
        if [ ! -f $dir/out.log ]; then
          touch $dir/out.log
        fi
      done

      /usr/sbin/service rsyslog restart

    <% end %>

    echo $$ > $PIDFILE

    while true; do sleep 10000; done

    ;;

  stop)
    kill_and_wait $PIDFILE 55
    ;;

  *)
    echo "Usage: syslog-configurator_ctl {start|stop}"
    ;;

esac

Remove exec from loop in syslog-configurator
Remove exec from loop in syslog-configurator

The exec was placed in the ctl script to avoid the creation of orphaned
sleep processes. This unfortunately led the infinite loop to break after
the first cycle. Why this is the case is still unknown, but for now we
will revert this change. The bug would cause syslog-configurator to stop,
which would be revived by monit, which would lead redis to also be
restart roughly every 10000 seconds.

[#141017007]

Signed-off-by: Maria Ntalla <db175d1e767b01513ca4f1524312ca03f02099ed@pivotal.io>
