Index: head/www/py-graphite-api/Makefile =================================================================== --- head/www/py-graphite-api/Makefile (revision 473978) +++ head/www/py-graphite-api/Makefile (revision 473979) @@ -1,72 +1,71 @@ # Created by: Dave Cottlehuber # $FreeBSD$ PORTNAME= graphite-api PORTVERSION= 1.1.3 +PORTREVISION= 1 CATEGORIES= www python MASTER_SITES= CHEESESHOP PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} -MAINTAINER= dch@skunkwerks.at +MAINTAINER= dch@FreeBSD.org COMMENT= Graphite-web, without the interface - just the rendering HTTP API LICENSE= APACHE20 RUN_DEPENDS= \ ${PYTHON_PKGNAMEPREFIX}pytz>0:devel/py-pytz@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}Flask>=0.10.1:www/py-flask@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}Flask-Cache>=0.13.1:www/py-flask-cache@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}tzlocal>=1.1.1:devel/py-tzlocal@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}structlog>=16.0.0:devel/py-structlog@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}pyparsing>=2.0.0:devel/py-pyparsing@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}yaml>3.1:devel/py-yaml@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}cairocffi>=0.7.2:graphics/py-cairocffi@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}gunicorn>=19.4.1:www/py-gunicorn@${PY_FLAVOR} \ xorg-fonts-truetype>=0:x11-fonts/xorg-fonts-truetype -NO_ARCH= yes USES= python USE_PYTHON= distutils py3kplist +NO_ARCH= yes + GRAPHITEAPI_APP= graphiteapi SUB_FILES= pkg-message -SUB_LIST= PORTNAME=${PORTNAME} \ - PREFIX=${PREFIX} \ +SUB_LIST= PYTHON_VER=${PYTHON_VER} \ + PYTHON_VERSION=${PYTHON_VERSION} \ GRAPHITEAPI_APP=${GRAPHITEAPI_APP} \ GRAPHITEAPI_USER=${GRAPHITEAPI_USER} \ GRAPHITEAPI_GROUP=${GRAPHITEAPI_GROUP} \ GRAPHITEAPI_LOGDIR=${GRAPHITEAPI_LOGDIR} \ GRAPHITEAPI_TMPDIR=${GRAPHITEAPI_TMPDIR} \ GRAPHITEAPI_PIDFILE=${GRAPHITEAPI_PIDFILE} -PLIST_SUB= PORTNAME=${PORTNAME} \ - PORTVERSION=${PORTVERSION} \ - PREFIX=${PREFIX} \ - GRAPHITEAPI_APP=${GRAPHITEAPI_APP} \ +PLIST_SUB= GRAPHITEAPI_APP=${GRAPHITEAPI_APP} \ GRAPHITEAPI_USER=${GRAPHITEAPI_USER} \ GRAPHITEAPI_GROUP=${GRAPHITEAPI_GROUP} \ GRAPHITEAPI_LOGDIR=${GRAPHITEAPI_LOGDIR} \ GRAPHITEAPI_TMPDIR=${GRAPHITEAPI_TMPDIR} \ GRAPHITEAPI_PIDFILE=${GRAPHITEAPI_PIDFILE} GRAPHITEAPI_USER?= carbon GRAPHITEAPI_GROUP?= carbon LOCALSTATEDIR= /var USE_RC_SUBR= ${GRAPHITEAPI_APP} GRAPHITEAPI_LOGDIR= ${LOCALSTATEDIR}/log/${GRAPHITEAPI_APP} GRAPHITEAPI_TMPDIR= ${LOCALSTATEDIR}/run/${GRAPHITEAPI_APP} GRAPHITEAPI_PIDFILE= ${LOCALSTATEDIR}/run/${GRAPHITEAPI_APP}/${GRAPHITEAPI_APP}.pid post-install: ${MKDIR} \ ${STAGEDIR}${ETCDIR} \ ${STAGEDIR}${GRAPHITEAPI_TMPDIR} \ ${STAGEDIR}${GRAPHITEAPI_LOGDIR} ${INSTALL_DATA} \ ${FILESDIR}/${GRAPHITEAPI_APP}.yaml.sample \ ${STAGEDIR}${ETCDIR}/${GRAPHITEAPI_APP}.yaml.sample .include Index: head/www/py-graphite-api/files/graphiteapi.in =================================================================== --- head/www/py-graphite-api/files/graphiteapi.in (revision 473978) +++ head/www/py-graphite-api/files/graphiteapi.in (revision 473979) @@ -1,52 +1,65 @@ #!/bin/sh # # $FreeBSD$ # # PROVIDE: graphiteapi # REQUIRE: LOGIN DAEMON NETWORKING # KEYWORD: shutdown # Add the following lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # # graphiteapi_enable (bool): Set to NO by default. # Set it to YES to enable graphiteapi. # # graphiteapi_user (string): optional username to run daemon under # graphiteapi_group (string): optional groupname to run daemon under # graphiteapi_address (string): optional IP:PORT tuple to bind to # graphiteapi_config (string): optional full path for yaml config file # graphiteapi_flags (string): optional flags to pass through to gunicorn . /etc/rc.subr name="%%GRAPHITEAPI_APP%%" rcvar="%%GRAPHITEAPI_APP%%_enable" +desc="graphite-web rendering API" -# defaults +load_rc_config ${name} + : ${graphiteapi_enable:="NO"} : ${graphiteapi_user="%%GRAPHITEAPI_USER%%"} : ${graphiteapi_group="%%GRAPHITEAPI_GROUP%%"} : ${graphiteapi_address="127.0.0.1:5600"} : ${graphiteapi_config="%%ETCDIR%%/%%GRAPHITEAPI_APP%%.yaml"} : ${graphiteapi_flags="--workers 4"} -# daemon -command="%%PREFIX%%/bin/gunicorn" required_files="${graphiteapi_config}" -command_args="graphite_api.app:app" + +command="%%PREFIX%%/bin/gunicorn-%%PYTHON_VER%%" +procname="%%PYTHON_VERSION%%" + +pidfile="%%GRAPHITEAPI_PIDFILE%%" + +command_args="--daemon graphite_api.app:app" command_args="${command_args} --user ${graphiteapi_user} --group ${graphiteapi_group}" command_args="${command_args} --bind ${graphiteapi_address}" -command_args="${command_args} --env TZ=UTC" command_args="${command_args} --env GRAPHITE_API_CONFIG=${graphiteapi_config}" command_args="${command_args} --pid %%GRAPHITEAPI_PIDFILE%%" command_args="${command_args} --worker-tmp-dir %%GRAPHITEAPI_TMPDIR%%" command_args="${command_args} --error-logfile %%GRAPHITEAPI_LOGDIR%%/error.log" command_args="${command_args} --access-logfile %%GRAPHITEAPI_LOGDIR%%/access.log" -# support SIGHUP to reload configuration file extra_commands="reload" +start_precmd="start_precmd" -load_rc_config $name +start_precmd() +{ + test -d "%%GRAPHITEAPI_LOGDIR%%" || install -d -o + ${graphiteapi_user} \ + -g ${graphiteapi_group} -m 0750 "%%GRAPHITEAPI_LOGDIR%%" + test -d "%%GRAPHITEAPI_TMPDIR%%" || install -d -o ${graphiteapi_user} \ + -g ${graphiteapi_group} -m 0750 "%%GRAPHITEAPI_TMPDIR%%" +} + run_rc_command "$1"