diff options
Diffstat (limited to 'www/py-gunicorn/files/gunicorn.in')
| -rw-r--r-- | www/py-gunicorn/files/gunicorn.in | 55 | 
1 files changed, 48 insertions, 7 deletions
| diff --git a/www/py-gunicorn/files/gunicorn.in b/www/py-gunicorn/files/gunicorn.in index 62e1fb68f56d..9ccf3fbc59f5 100644 --- a/www/py-gunicorn/files/gunicorn.in +++ b/www/py-gunicorn/files/gunicorn.in @@ -6,9 +6,17 @@  # KEYWORD: shutdown  #  # Add the following lines to /etc/rc.conf to enable gunicorn: -#  gunicorn_enable (bool):    Set to "NO" by default. -#                       Set it to "YES" to enable gunicorn. +#  gunicorn_enable (bool):  Set to "NO" by default. +#			    Set it to "YES" to enable gunicorn.  # +# gunicorn_config (str):    Path to gunicorn config file. +# +# gunicorn_user (str):      User to run gunicorn as. +# +# gunicorn_group (str):     Group to run gunicorn as. +# +# gunicorn_profiles (str):  Set to "" by default. +#                           Define your profiles here.  . /etc/rc.subr @@ -20,17 +28,50 @@ rcvar=gunicorn_enable  load_rc_config $name  : ${gunicorn_enable:=NO} -: ${gunicorn_config=%%PREFIX%%/etc/gunicorn/gunicorn.conf.py} -: ${gunicorn_user=%%USERS%%} -: ${gunicorn_group=%%GROUPS%%} +: ${gunicorn_config:=%%PREFIX%%/etc/gunicorn/gunicorn.conf.py} +: ${gunicorn_user:=%%USERS%%} +: ${gunicorn_group:=%%GROUPS%%} -pidfile="/var/run/${name}.pid" -cpidfile="/var/run/${name}-worker.pid" +_pidprefix="/var/run/gunicorn" +pidfile="${_pidprefix}/${name}.pid" +cpidfile="${_pidprefix}/${name}-worker.pid"  command=/usr/sbin/daemon  command_args="-P ${pidfile} -p ${cpidfile} -f -ST ${name} %%PREFIX%%/bin/gunicorn -c ${gunicorn_config}"  required_files="${gunicorn_config}"  start_precmd="gunicorn_precmd" +if [ -n "$2" ]; then +	profile="$2" +	if [ "x${gunicorn_profiles}" != "x" ]; then +		pidfile="${_pidprefix}/gunicorn-${profile}.pid" +		cpidfile="${_pidprefix}/gunicorn-${profile}-worker.pid" +		eval gunicorn_config="\${gunicorn_${profile}_config:-}" +		if [ "x${gunicorn_config}" = "x" ]; then +			echo "You must define a configuration file (gunicorn_${profile}_config)" +			exit 1 +		fi +		required_files="${gunicorn_config}" +		command_args="-P ${pidfile} -p ${cpidfile} -f -ST ${name} /usr/local/bin/gunicorn -c ${gunicorn_config}" +		eval gunicorn_enable="\${gunicorn_${profile}_enable:-${gunicorn_enable}}" +	else +		echo "$0: extra argument ignored" +	fi +else +	if [ "x${gunicorn_profiles}" != "x" -a "x$1" != "x" ]; then +		for profile in ${gunicorn_profiles}; do +			echo "===> gunicorn profile: ${profile}" +			%%PREFIX%%/etc/rc.d/gunicorn $1 ${profile} +			retcode="$?" +			if [ "0${retcode}" -ne 0 ]; then +				failed="${profile} (${retcode}) ${failed:-}" +			else +				success="${profile} ${success:-}" +			fi +		done +		exit 0 +	fi +fi +  gunicorn_precmd()  {  	install -o ${gunicorn_user} /dev/null ${pidfile} | 
