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/nodepool
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.

Also expose zuulv3 flag to user to toggle the location of pidfile,
this changes in nodepool > 0.5.0.

Change-Id: I7fff2565f9e77d737c247f204925f66a0e4aabe8
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2018-01-17 13:47:20 -05:00
parent e2b8c27908
commit 078f336a01
No known key found for this signature in database
GPG Key ID: 611A80832067AF38
3 changed files with 16 additions and 4 deletions

View File

@ -33,6 +33,8 @@ USER=nodepool
# 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
#
@ -43,8 +45,10 @@ do_start()
# 1 if daemon was already running
# 2 if daemon could not be started
mkdir -p /var/run/$NAME
chown $USER /var/run/$NAME
if [ ! -d "$PIDFILE_DIR" ] ; then
mkdir -p $PIDFILE_DIR
chown $USER $PIFILE_DIR
fi
ulimit -n 8192
start-stop-daemon --start --quiet --pidfile $PIDFILE -c $USER --exec $DAEMON --test > /dev/null \
|| return 1
@ -69,7 +73,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"
}
@ -98,7 +104,9 @@ do_graceful_stop()
done
fi
rm -f /var/run/$NAME/*
if [ -f "$PIDFILE" ] ; then
rm -f $PIDFILE
fi
}
#

View File

@ -22,6 +22,7 @@ class nodepool::builder(
$environment = {},
$build_workers = '1',
$upload_workers = '4',
$zuulv3 = false,
) {
include ::diskimage_builder

View File

@ -5,4 +5,7 @@ export STATSD_PORT=8125
<% @environment.keys.sort.each do |key| -%>
export <%= key %>='<%= @environment[key] %>'
<% end -%>
<% if @zuulv3 -%>
PIDFILE=/var/run/nodepool/nodepool-builder.pid
<% end -%>
DAEMON_ARGS="-c /etc/nodepool/nodepool.yaml -l /etc/nodepool/builder-logging.conf --build-workers <%= @build_workers %> --upload-workers <%= @upload_workers %>"