#!/bin/bash -e

set -e

job_dir=/var/vcap/jobs/cf-mysql-broker
run_dir=/var/vcap/sys/run/quota-enforcer
log_dir=/var/vcap/sys/log/quota-enforcer
package_dir=/var/vcap/packages/quota-enforcer
pidfile=$run_dir/quota-enforcer.pid

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

case $1 in

  start)
    pid_guard $pidfile "quota-enforcer"

    mkdir -p $run_dir
    mkdir -p $log_dir

    echo $$ > $pidfile

    $package_dir/bin/cf-mysql-quota-enforcer \
        -configPath=$job_dir/bin/quota_enforcer_config.yml \
     >>$log_dir/quota_enforcer.stdout.log 2>>$log_dir/quota_enforcer.stderr.log
    ;;

  stop)
    kill_and_wait $pidfile
    ;;

  *)
    echo "Usage: cf-mysql-quota-enforcer_ctl {start|stop}"
    ;;

esac

#!/bin/bash -e

set -e

job_dir=/var/vcap/jobs/cf-mysql-broker
run_dir=/var/vcap/sys/run/quota-enforcer
log_dir=/var/vcap/sys/log/quota-enforcer
package_dir=/var/vcap/packages/quota-enforcer
pidfile=$run_dir/quota-enforcer.pid

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

case $1 in

  start)
    pid_guard $pidfile "quota-enforcer"

    mkdir -p $run_dir
    mkdir -p $log_dir

    $package_dir/bin/cf-mysql-quota-enforcer \
        -pidFile=$pidfile \
        -configPath=$job_dir/bin/quota_enforcer_config.yml \
     >>$log_dir/quota_enforcer.stdout.log 2>>$log_dir/quota_enforcer.stderr.log
    ;;

  stop)
    kill_and_wait $pidfile
    ;;

  *)
    echo "Usage: cf-mysql-quota-enforcer_ctl {start|stop}"
    ;;

esac

Write PID of quota-enforcer process rather than wrapper script.
Write PID of quota-enforcer process rather than wrapper script.

- Quota-enforcer process now writes own pid to pidfile
- Allows monit to kill and restart the enforcer process rather than the
wrapper

[Fixes #99640614]

Signed-off-by: Frank Kotsianas <46dc4204864162cbc55f90455292577144d430e9@pivotal.io>
