From b513d9845e3757c63212adccfae4321a64b3ac43 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Tue, 2 Jan 2018 16:30:53 -0800 Subject: [PATCH] Don't assume pidfile location When configuring the dir for the pidfiles in our init scripts don't assume the path is /var/run/$NAME. The defaults are now /var/run/zuul now and could be set to other values as well. Instead of assuming /var/run/$NAME we instead take the dirname of $PIDFILE and configure whatever that dir is instead. Change-Id: Idfd5d19e5171278b9bb7005edb4ae927a01f3615 --- files/zuul-executor.init | 12 +++++++++--- files/zuul-fingergw.init | 12 +++++++++--- files/zuul-merger.init | 12 +++++++++--- files/zuul-scheduler.init | 12 +++++++++--- files/zuul-web.init | 12 +++++++++--- 5 files changed, 45 insertions(+), 15 deletions(-) diff --git a/files/zuul-executor.init b/files/zuul-executor.init index 06bfdb9..b9e8f1a 100644 --- a/files/zuul-executor.init +++ b/files/zuul-executor.init @@ -33,6 +33,8 @@ USER=root # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions +PIDFILE_DIR=$(dirname $PIDFILE) + # # Function that starts the daemon/service # @@ -44,8 +46,10 @@ do_start() # 2 if daemon could not be started # 3 if pid file already exist - mkdir -p /var/run/$NAME - chown $USER /var/run/$NAME + if [ ! -d "$PIDFILE_DIR" ] ; then + mkdir -p $PIDFILE_DIR + chown $USER $PIDFILE_DIR + fi ulimit -n 8192 ulimit -c unlimited if [ -f $PIDFILE ]; then @@ -68,7 +72,9 @@ do_start() do_stop() { $DAEMON stop - rm -f /var/run/$NAME/* + if [ -f "$PIDFILE" ] ; then + rm -f $PIDFILE + fi return 0 } diff --git a/files/zuul-fingergw.init b/files/zuul-fingergw.init index 080cae2..c5019ff 100644 --- a/files/zuul-fingergw.init +++ b/files/zuul-fingergw.init @@ -33,6 +33,8 @@ USER=root # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions +PIDFILE_DIR=$(dirname $PIDFILE) + # # Function that starts the daemon/service # @@ -44,8 +46,10 @@ do_start() # 2 if daemon could not be started # 3 if pid file already exist - mkdir -p /var/run/$NAME - chown $USER /var/run/$NAME + if [ ! -d "$PIDFILE_DIR" ] ; then + mkdir -p $PIDFILE_DIR + chown $USER $PIDFILE_DIR + fi ulimit -n 8192 if [ -f $PIDFILE ]; then return 3 @@ -74,7 +78,9 @@ do_stop() start-stop-daemon --stop --signal 9 --pidfile $PIDFILE RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 - rm -f /var/run/$NAME/* + if [ -f "$PIDFILE" ] ; then + rm -f $PIDFILE + fi return "$RETVAL" } diff --git a/files/zuul-merger.init b/files/zuul-merger.init index be6740e..13170b6 100644 --- a/files/zuul-merger.init +++ b/files/zuul-merger.init @@ -33,6 +33,8 @@ USER=zuul # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions +PIDFILE_DIR=$(dirname $PIDFILE) + # # Function that starts the daemon/service # @@ -44,8 +46,10 @@ do_start() # 2 if daemon could not be started # 3 if pid file already exist - mkdir -p /var/run/$NAME - chown $USER /var/run/$NAME + if [ ! -d "$PIDFILE_DIR" ] ; then + mkdir -p $PIDFILE_DIR + chown $USER $PIDFILE_DIR + fi ulimit -n 8192 if [ -f $PIDFILE ]; then return 3 @@ -74,7 +78,9 @@ do_stop() start-stop-daemon --stop --signal 9 --pidfile $PIDFILE RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 - rm -f /var/run/$NAME/* + if [ -f "$PIDFILE" ] ; then + rm -f $PIDFILE + fi return "$RETVAL" } diff --git a/files/zuul-scheduler.init b/files/zuul-scheduler.init index 458c355..b8f18ce 100644 --- a/files/zuul-scheduler.init +++ b/files/zuul-scheduler.init @@ -33,6 +33,8 @@ USER=zuul # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions +PIDFILE_DIR=$(dirname $PIDFILE) + # # Function that starts the daemon/service # @@ -44,8 +46,10 @@ do_start() # 2 if daemon could not be started # 3 if pid file exits already - mkdir -p /var/run/$NAME - chown $USER /var/run/$NAME + if [ ! -d "$PIDFILE_DIR" ] ; then + mkdir -p $PIDFILE_DIR + chown $USER $PIDFILE_DIR + fi ulimit -n 8192 if [ -f $PIDFILE ]; then return 3 @@ -74,7 +78,9 @@ do_stop() start-stop-daemon --stop --signal 9 --pidfile $PIDFILE RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 - rm -f /var/run/$NAME/* + if [ -f "$PIDFILE" ] ; then + rm -f $PIDFILE + fi return "$RETVAL" } diff --git a/files/zuul-web.init b/files/zuul-web.init index f0fd3fa..3dbcfca 100644 --- a/files/zuul-web.init +++ b/files/zuul-web.init @@ -33,6 +33,8 @@ USER=zuul # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions +PIDFILE_DIR=$(dirname $PIDFILE) + # # Function that starts the daemon/service # @@ -44,8 +46,10 @@ do_start() # 2 if daemon could not be started # 3 if pid file already exist - mkdir -p /var/run/$NAME - chown $USER /var/run/$NAME + if [ ! -d "$PIDFILE_DIR" ] ; then + mkdir -p $PIDFILE_DIR + chown $USER $PIDFILE_DIR + fi ulimit -n 8192 if [ -f $PIDFILE ]; then return 3 @@ -74,7 +78,9 @@ do_stop() start-stop-daemon --stop --signal 9 --pidfile $PIDFILE RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 - rm -f /var/run/$NAME/* + if [ -f "$PIDFILE" ] ; then + rm -f $PIDFILE + fi return "$RETVAL" }