view modules/python/templates/gunicorn.rhel.init.erb @ 183:ac164022ffb8 puppet-3.6

Try to fix "Garbage after numerical service in server description" Based on the logged config text ([127.0.0.1]:10024readme_dire...) it appears to be caused by a lack of blank line and something adding extra config values (because we don't define readme_directory)
author IBBoard <dev@ibboard.co.uk>
date Fri, 07 Dec 2018 19:54:20 +0000
parents 956e484adc12
children
line wrap: on
line source

#!/bin/sh
### BEGIN INIT INFO
# Provides:          gunicorn-<%= name %>
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the gunicorn server for <%= name %>
# Description:       starts the gunicorn server for <%= name %>
### END INIT INFO

NAME=gunicorn-<%= name %>
DESC=$NAME
VENV=<%= venv %>
SRC=<%= src %>
DAEMON=$VENV/bin/gunicorn<% if django %>_django<% end %><% if paste %>_paster<% end %>
<% if owner == 'undef' or group == 'undef' %>
CHOWN=""
<% else %>
CHOWN="--user <%= owner %>"
<% end %>
SOCKET=<%= socket %>
RUNDIR=<%= rundir %>
PIDFILE=<%= pidfile %>
LOGFILE=<%= logfile %>
WORKERS=<%= workers %>
TIMEOUT=<%= timeout_seconds %>
MODULE=<%= django ? django_settings : (paste ? paste_settings : wsgi_module) %>
<% if django %>
PYTHONPATH_PARAM="--pythonpath $SRC"
<% else %>
PYTHONPATH_PARAM=""
<% end %>
<% if conffile == '' %>
CONFFILE=""
<% else %>
CONFFILE="-c <%= conffile %>"
<% end %>

DAEMON_OPTS="$CONFFILE -b $SOCKET -p $PIDFILE --log-file $LOGFILE \
--workers $WORKERS -t $TIMEOUT --daemon --name $NAME \
$PYTHONPATH_PARAM $MODULE"

test -x $DAEMON || exit 0

. /etc/rc.d/init.d/functions

set -e

if [ ! -d $RUNDIR ]; then
  mkdir -p $RUNDIR
  <% if owner != 'undef' and group != 'undef' %>
  chown <%= owner %>:<%= group%> $RUNDIR
  <% end %>
fi

case "$1" in
  start)
    echo -n "Starting $DESC: "
    cd $SRC
    daemon $CHOWN --pidfile $PIDFILE $DAEMON $DAEMON_OPTS || true
    echo "$NAME."
	;;
  stop)
    echo -n "Stopping $DESC: "
    killproc -p $PIDFILE -QUIT $NAME || true
    echo "$NAME."
	;;
  restart)
    echo -n "Restarting $DESC: "
    killproc -p $PIDFILE -QUIT $NAME || true
    sleep 1
    cd $SRC
    daemon $CHOWN --pidfile $PIDFILE $DAEMON $DAEMON_OPTS || true
    echo "$NAME."
	;;
  reload)
    echo -n "Reloading $DESC: "
    killproc -p $PIDFILE -HUP $NAME || true
    echo "$NAME."
	;;
  status)
    status -p $PIDFILE $name || exit $?
	;;
  *)
	echo "Usage: $NAME {start|stop|restart|status}" >&2
	exit 1
	;;
esac

exit 0