stacktach-sandbox/ansible/roles/stv3-workers/templates/yagi-event.debian.init.d.j2
Sandy Walsh 618cdcdd63 Cell Support
Yagi-workers are now created per cell. One rabbit per cell.
Also renamed the common role to stv3-common to prevent conflicts
with other playbooks.

Take note of ansible/roles/stv3-workers/defaults/main.yaml to
see an example of the expected format of the calling facts file.
Each entry in this list-of-dictionaries represents a rabbit server
and Swift container for that cell.

Also, multiple pipeline_workers are created based on the value
of num_pipeline_workers (defaults to 2). This is so a machine
can better utilize multi-core architectures.

Change-Id: I09c4d364878493546d6e23e019f01f5f4f38c37c
2014-12-22 10:14:37 -08:00

102 lines
2.6 KiB
Django/Jinja

#! /bin/sh
### BEGIN INIT INFO
# Provides: YAGI worker service
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: YAGI worker daemon control.
# Description: YAGI worker daemon control.
### END INIT INFO
# Author: Sandy Walsh <sandy.walsh@rackspace.com>
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/opt/stv3/bin:/sbin:/usr/sbin:/bin:/usr/bin
DESC="YAGI worker control"
NAME=yagi-event
CELLNAME=yagi-event-{{item.cell}}
DAEMON=/opt/stv3/bin/$NAME
DAEMON_ARGS="--config /etc/stv3/yagi.conf"
PIDFILE=/var/run/stv3/$CELLNAME.pid
SCRIPTNAME=/etc/init.d/$CELLNAME
USER=stv3
GROUP=stv3
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$CELLNAME ] && . /etc/default/$CELLNAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
VERBOSE=yes
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
. /opt/stv3/bin/activate
winchester_db -c /etc/stv3/winchester.yaml upgrade head
start-stop-daemon --start --name ${NAME} --chdir /var/run/stv3 \
--chuid ${USER}:${GROUP} --background \
--make-pidfile --pidfile ${PIDFILE} \
--exec ${DAEMON} -- ${DAEMON_ARGS}
}
#
# Function that stops the daemon/service
#
do_stop()
{
. /opt/stv3/bin/activate
log_daemon_msg "Stopping ${DAEMON}... " ${DAEMON}
start-stop-daemon --stop --oknodo --pidfile ${PIDFILE} --retry=TERM/30/KILL/5
log_end_msg $?
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$CELLNAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$CELLNAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$CELLNAME" && exit 0 || exit $?
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$CELLNAME"
do_stop
do_start
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
: