Bug 181043

Summary: [patch] databases/py-carbon: Enhance the init script
Product: Ports & Packages Reporter: Brad Davis <brd>
Component: Individual Port(s)Assignee: Steve Wills <swills>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
py-carbon.patch none

Description Brad Davis freebsd_committer freebsd_triage 2013-08-05 04:20:00 UTC
	Enhance the init script to require the appropriate config files and fix the stop routine to wait for the server to exit.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-08-05 04:20:14 UTC
Responsible Changed
From-To: freebsd-ports-bugs->freebsd-python

freebsd-python@ wants this port PRs (via the GNATS Auto Assign Tool)
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2013-08-05 04:20:15 UTC
Maintainer of databases/py-carbon,

Please note that PR ports/181043 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/181043

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 3 Edwin Groothuis freebsd_committer freebsd_triage 2013-08-05 04:20:16 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 4 Ryan Steinmetz freebsd_committer freebsd_triage 2013-08-19 22:55:23 UTC
Responsible Changed
From-To: freebsd-python->zi

I'll take it.
Comment 5 Steve Wills freebsd_committer freebsd_triage 2013-12-22 18:42:49 UTC
Responsible Changed
From-To: zi->swills

I'll take it.
Comment 6 dfilter service freebsd_committer freebsd_triage 2014-02-18 15:44:06 UTC
Author: swills
Date: Tue Feb 18 15:43:57 2014
New Revision: 344911
URL: http://svnweb.freebsd.org/changeset/ports/344911
QAT: https://qat.redports.org/buildarchive/r344911/

Log:
  - 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)

Added:
  head/databases/py-carbon/files/patch-conf__carbon.amqp.conf.example   (contents, props changed)
  head/databases/py-carbon/files/patch-conf__carbon.conf.example   (contents, props changed)
  head/databases/py-carbon/files/patch-lib__carbon__util.py   (contents, props changed)
Modified:
  head/databases/py-carbon/Makefile
  head/databases/py-carbon/files/carbon.in   (contents, props changed)
  head/databases/py-carbon/files/patch-setup.py
  head/databases/py-carbon/pkg-plist

Modified: head/databases/py-carbon/Makefile
==============================================================================
--- head/databases/py-carbon/Makefile	Tue Feb 18 15:37:31 2014	(r344910)
+++ head/databases/py-carbon/Makefile	Tue Feb 18 15:43:57 2014	(r344911)
@@ -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>

Modified: head/databases/py-carbon/files/carbon.in
==============================================================================
--- head/databases/py-carbon/files/carbon.in	Tue Feb 18 15:37:31 2014	(r344910)
+++ head/databases/py-carbon/files/carbon.in	Tue Feb 18 15:43:57 2014	(r344911)
@@ -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"

Added: head/databases/py-carbon/files/patch-conf__carbon.amqp.conf.example
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/py-carbon/files/patch-conf__carbon.amqp.conf.example	Tue Feb 18 15:43:57 2014	(r344911)
@@ -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

Added: head/databases/py-carbon/files/patch-conf__carbon.conf.example
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/py-carbon/files/patch-conf__carbon.conf.example	Tue Feb 18 15:43:57 2014	(r344911)
@@ -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

Added: head/databases/py-carbon/files/patch-lib__carbon__util.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/py-carbon/files/patch-lib__carbon__util.py	Tue Feb 18 15:43:57 2014	(r344911)
@@ -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

Modified: head/databases/py-carbon/files/patch-setup.py
==============================================================================
--- head/databases/py-carbon/files/patch-setup.py	Tue Feb 18 15:37:31 2014	(r344910)
+++ head/databases/py-carbon/files/patch-setup.py	Tue Feb 18 15:43:57 2014	(r344911)
@@ -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

Modified: head/databases/py-carbon/pkg-plist
==============================================================================
--- head/databases/py-carbon/pkg-plist	Tue Feb 18 15:37:31 2014	(r344910)
+++ head/databases/py-carbon/pkg-plist	Tue Feb 18 15:43:57 2014	(r344911)
@@ -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%%
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 7 Steve Wills freebsd_committer freebsd_triage 2014-02-18 15:44:16 UTC
State Changed
From-To: feedback->closed

Committed, with minor changes. Thanks!