- Enhance init script [1]

- Fix with newer Django [2]
- Lots of other cleanups and improvements, including moving the data to a more
  standard location
- Take maintainership, maintainer has not responded to PRs in many months

PR:		ports/181043 [1]
PR:		ports/185097 [2]
Submitted by:	brd [1]
Submitted by:	swills (myself) [2]
Approved by:	maintainer timeout (bsdports@wayfair.com, >3 months)
This commit is contained in:
Steve Wills 2014-02-18 15:43:57 +00:00
parent 7a59446bf9
commit f25b2a7304
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=344911
7 changed files with 94 additions and 34 deletions

View file

@ -3,23 +3,25 @@
PORTNAME= carbon
PORTVERSION= 0.9.12
PORTREVISION= 1
CATEGORIES= databases python
MASTER_SITES= https://github.com/graphite-project/${PORTNAME}/archive/${PORTVERSION}.tar.gz?dummy=
MASTER_SITES= http://github.com/graphite-project/${PORTNAME}/archive/${PORTVERSION}.tar.gz?dummy=/
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
MAINTAINER= bsdports@wayfair.com
MAINTAINER= swills@FreeBSD.org
COMMENT= Backend storage application for graphite
LICENSE= APACHE20
RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}txamqp>=0.3:${PORTSDIR}/net/py-txamqp \
${PYTHON_PKGNAMEPREFIX}whisper>=0.9.10:${PORTSDIR}/databases/py-whisper
${PYTHON_PKGNAMEPREFIX}whisper>=0.9.10:${PORTSDIR}/databases/py-whisper \
${PYTHON_PKGNAMEPREFIX}django>=1.4:${PORTSDIR}/www/py-django
USE_PYTHON= 2
USE_PYDISTUTILS= yes
USES= twisted:run
FETCH_ARGS= -o ${DISTNAME}${EXTRACT_SUFX}
USE_RC_SUBR= carbon
PLIST_SUB+= RESETPREFIX=${PREFIX}
NO_STAGE= yes
.include <bsd.port.mk>

View file

@ -1,13 +1,19 @@
#!/bin/sh
#
#
# $FreeBSD$
#
# PROVIDE: carbon
# KEYWORD: shutdown
#
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# carbon_enable (bool): Set to NO by default.
# Set it to YES to enable it.
# carbon_conf: File where carbon configuration resides
# Default: %%PREFIX%%/etc/carbon/carbon.conf
# carbon_user: The user account carbon daemon runs as what
# you want it to be. It uses 'root' user by
# default.
@ -18,43 +24,38 @@
# mode, it may be very verbose. It will not run
# in debug by default.
# carbon_logdir: Directory where carbon logs are stored.
# Default: /usr/local/graphite/storage/log
# carbon_conf: File where carbon configuration resides
# Default: /usr/local/etc/carbon/carbon.conf
# carbon_pidfile: Location where carbon should place its pid file
# Default: /var/run/carbon.pid
# Default: /var/db/carbon/log
#
. /etc/rc.subr
name="carbon"
rcvar=${name}_enable
name=carbon
rcvar=carbon_enable
load_rc_config ${name}
: ${carbon_enable:="NO"}
: ${carbon_user:="root"}
: ${carbon_group:="wheel"}
: ${carbon_conf:="/usr/local/etc/carbon/carbon.conf"}
: ${carbon_debug:="NO"}
: ${carbon_logdir:="/usr/local/graphite/storage/log"}
: ${carbon_pidfile:="/var/run/carbon.pid"}
: ${carbon_enable:=NO}
: ${carbon_user:=root}
: ${carbon_group:=wheel}
: ${carbon_conf:=%%PREFIX%%/etc/carbon/carbon.conf}
: ${carbon_debug:=NO}
: ${carbon_logdir:=/var/db/carbon/log/}
: ${pidfile:=/var/run/carbon.pid}
status_cmd="${name}_status"
stop_cmd="${name}_stop"
required_files="${carbon_conf} %%PREFIX%%/etc/carbon/storage-schemas.conf"
command_interpreter="/usr/local/bin/python2.7"
command="/usr/local/bin/carbon-cache.py"
command_args="--config=${carbon_conf} --logdir ${carbon_logdir} --pidfile ${carbon_pidfile} start"
command_interpreter="%%PREFIX%%/bin/python2.7"
command="%%PREFIX%%/bin/carbon-cache.py"
command_args="--config=${carbon_conf} --logdir ${carbon_logdir} --pidfile ${pidfile} start"
carbon_stop() {
carbon_stop()
{
echo "Stopping $name"
pids=`check_pidfile ${pidfile} ${command} ${command_interpreter}`
/usr/local/bin/carbon-cache.py --config=${carbon_conf} --pidfile ${carbon_pidfile} stop
}
carbon_status() {
/usr/local/bin/carbon-cache.py --config=${carbon_conf} --pidfile ${carbon_pidfile} status
%%PREFIX%%/bin/carbon-cache.py --config=${carbon_conf} --pidfile ${pidfile} stop
wait_for_pids ${pids}
}
run_rc_command "$1"

View file

@ -0,0 +1,11 @@
--- conf/carbon.amqp.conf.example.orig 2014-02-13 17:04:10.949705742 +0000
+++ conf/carbon.amqp.conf.example 2014-02-13 17:04:42.404703056 +0000
@@ -1,7 +1,7 @@
# This is a configuration file with AMQP enabled
[cache]
-LOCAL_DATA_DIR =
+LOCAL_DATA_DIR = /var/db/carbon/whisper
# Specify the user to drop privileges to
# If this is blank carbon runs as the user that invokes it

View file

@ -0,0 +1,10 @@
--- conf/carbon.conf.example.orig 2014-02-13 16:47:59.689772807 +0000
+++ conf/carbon.conf.example 2014-02-13 16:48:17.904771292 +0000
@@ -29,6 +29,7 @@
# PID_DIR = /var/run/
#
#LOCAL_DATA_DIR = /opt/graphite/storage/whisper/
+LOCAL_DATA_DIR = /var/db/carbon/whisper/
# Enable daily log rotation. If disabled, a kill -HUP can be used after a manual rotate
ENABLE_LOGROTATION = True

View file

@ -0,0 +1,11 @@
--- ./lib/carbon/util.py.orig 2013-12-22 16:45:46.061449090 +0000
+++ ./lib/carbon/util.py 2013-12-22 16:46:00.326083639 +0000
@@ -18,7 +18,7 @@
from time import sleep, time
from twisted.python.util import initgroups
from twisted.scripts.twistd import runApp
-from twisted.scripts._twistd_unix import daemonize
+from django.utils import daemonize
daemonize = daemonize # Backwards compatibility

View file

@ -7,8 +7,8 @@
-storage_dirs = [ ('storage/whisper',[]), ('storage/lists',[]),
- ('storage/log',[]), ('storage/rrd',[]) ]
-conf_files = [ ('conf', glob('conf/*.example')) ]
+storage_dirs = [ ('/var/db/graphite/storage/whisper',[]), ('/var/db/graphite/storage/lists',[]),
+ ('/var/db/graphite/storage/log',[]), ('/var/db/graphite/storage/rrd',[]) ]
+storage_dirs = [ ('/var/db/carbon/whisper',[]), ('/var/db/carbon/lists',[]),
+ ('/var/db/carbon/log',[]), ('/var/db/carbon/rrd',[]) ]
+conf_files = [ ('/usr/local/etc/carbon', glob('conf/*.example')) ]
install_files = storage_dirs + conf_files

View file

@ -3,15 +3,33 @@ bin/carbon-cache.py
bin/carbon-client.py
bin/carbon-relay.py
bin/validate-storage-schemas.py
@unexec if cmp -s %D/etc/carbon/rewrite-rules.conf.example %D/etc/carbon/rewrite-rules.conf; then rm -f %D/etc/carbon/rewrite-rules.conf; fi
%%ETCDIR%%/rewrite-rules.conf.example
@exec if [ ! -f %D/etc/carbon/rewrite-rules.conf ] ; then cp -p %D/%F %B/rewrite-rules.conf; fi
@unexec if cmp -s %D/etc/carbon/carbon.amqp.conf.example %D/etc/carbon/carbon.amqp.conf; then rm -f %D/etc/carbon/carbon.amqp.conf; fi
%%ETCDIR%%/carbon.amqp.conf.example
@exec if [ ! -f %D/etc/carbon/carbon.amqp.conf ] ; then cp -p %D/%F %B/carbon.amqp.conf; fi
@unexec if cmp -s %D/etc/carbon/carbon.conf.example %D/etc/carbon/carbon.conf; then rm -f %D/etc/carbon/carbon.conf; fi
%%ETCDIR%%/carbon.conf.example
@exec if [ ! -f %D/etc/carbon/carbon.conf ] ; then cp -p %D/%F %B/carbon.conf; fi
@unexec if cmp -s %D/etc/carbon/aggregation-rules.conf.example %D/etc/carbon/aggregation-rules.conf; then rm -f %D/etc/carbon/aggregation-rules.conf; fi
%%ETCDIR%%/aggregation-rules.conf.example
@exec if [ ! -f %D/etc/carbon/aggregation-rules.conf ] ; then cp -p %D/%F %B/aggregation-rules.conf; fi
@unexec if cmp -s %D/etc/carbon/relay-rules.conf.example %D/etc/carbon/relay-rules.conf; then rm -f %D/etc/carbon/relay-rules.conf; fi
%%ETCDIR%%/relay-rules.conf.example
@exec if [ ! -f %D/etc/carbon/relay-rules.conf ] ; then cp -p %D/%F %B/relay-rules.conf; fi
@unexec if cmp -s %D/etc/carbon/storage-schemas.conf.example %D/etc/carbon/storage-schemas.conf; then rm -f %D/etc/carbon/storage-schemas.conf; fi
%%ETCDIR%%/storage-schemas.conf.example
@exec if [ ! -f %D/etc/carbon/storage-schemas.conf ] ; then cp -p %D/%F %B/storage-schemas.conf; fi
@unexec if cmp -s %D/etc/carbon/blacklist.conf.example %D/etc/carbon/blacklist.conf; then rm -f %D/etc/carbon/blacklist.conf; fi
%%ETCDIR%%/blacklist.conf.example
@exec if [ ! -f %D/etc/carbon/blacklist.conf ] ; then cp -p %D/%F %B/blacklist.conf; fi
@unexec if cmp -s %D/etc/carbon/storage-aggregation.conf.example %D/etc/carbon/storage-aggregation.conf; then rm -f %D/etc/carbon/storage-aggregation.conf; fi
%%ETCDIR%%/storage-aggregation.conf.example
@exec if [ ! -f %D/etc/carbon/storage-aggregation.conf ] ; then cp -p %D/%F %B/storage-aggregation.conf; fi
@unexec if cmp -s %D/etc/carbon/whitelist.conf.example %D/etc/carbon/whitelist.conf; then rm -f %D/etc/carbon/whitelist.conf; fi
%%ETCDIR%%/whitelist.conf.example
@exec if [ ! -f %D/etc/carbon/whitelist.conf ] ; then cp -p %D/%F %B/whitelist.conf; fi
%%PYTHON_SITELIBDIR%%/twisted/plugins/carbon_aggregator_plugin.py
%%PYTHON_SITELIBDIR%%/twisted/plugins/carbon_relay_plugin.py
%%PYTHON_SITELIBDIR%%/twisted/plugins/carbon_cache_plugin.py
@ -103,6 +121,13 @@ bin/validate-storage-schemas.py
%%PYTHON_SITELIBDIR%%/carbon/regexlist.py
%%PYTHON_SITELIBDIR%%/carbon/regexlist.pyc
%%PYTHON_SITELIBDIR%%/carbon/regexlist.pyo
@dirrm %%ETCDIR%%
@dirrm %%PYTHON_SITELIBDIR%%/carbon/aggregator
@dirrm %%PYTHON_SITELIBDIR%%/carbon
@dirrmtry %%ETCDIR%%
@cwd /
@dirrmtry var/db/carbon/whisper
@dirrmtry var/db/carbon/rrd
@dirrmtry var/db/carbon/log
@dirrmtry var/db/carbon/lists
@dirrmtry var/db/carbon
@cwd %%RESETPREFIX%%