#!/bin/bash

set -e -x

RUN_DIR=/var/vcap/sys/run/nginx_bits
LOG_DIR=/var/vcap/sys/log/nginx_bits
UPLOADS_DIR=/var/vcap/data/bits-service/tmp/uploads
PIDFILE=$RUN_DIR/nginx.pid
JOB_DIR=/var/vcap/jobs/bits-service

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

case $1 in

  start)
    pid_guard $PIDFILE "Nginx"

    mkdir -p $RUN_DIR
    mkdir -p $LOG_DIR

    echo $$ > $PIDFILE

    if [ ! -d "$UPLOADS_DIR" ]; then
      chpst -u vcap:vcap mkdir -p $UPLOADS_DIR
    fi

    exec /var/vcap/packages/nginx/sbin/nginx \
         -c $JOB_DIR/config/nginx.conf
    ;;

  stop)
    #force kill immediately; drain script should have already run
    kill_and_wait $PIDFILE 0 1

    ;;

  *)
    echo "Usage: nginx_ctl {start|stop}"

    ;;

esac

#!/bin/bash

set -e -x

RUN_DIR=/var/vcap/sys/run/nginx_bits
LOG_DIR=/var/vcap/sys/log/nginx_bits
UPLOADS_DIR=/var/vcap/data/bits-service/tmp/uploads
PIDFILE=$RUN_DIR/nginx.pid
JOB_DIR=/var/vcap/jobs/bits-service

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

case $1 in

  start)
    pid_guard $PIDFILE "Nginx"

    mkdir -p $RUN_DIR
    mkdir -p $LOG_DIR

    echo $$ > $PIDFILE

    if [ ! -d "$UPLOADS_DIR" ]; then
      chpst -u vcap:vcap mkdir -p $UPLOADS_DIR
    fi

    exec /var/vcap/packages/nginx/sbin/nginx \
         -c $JOB_DIR/config/nginx.conf
    ;;

  stop)
    #force kill immediately; drain script should have already run
    kill_and_wait $PIDFILE

    ;;

  *)
    echo "Usage: nginx_ctl {start|stop}"

    ;;

esac

Use defaults for `kill_and_wait` with nginx
Use defaults for `kill_and_wait` with nginx

Signed-off-by: Tiago Scolari <f438736fd7dd1cb07f8d2a37f4499d0a0272a752@pivotal.io>
