Permalink
Browse files

SysVinit improvements for Carbon

- Standardized naming to make things more specific.
- Old carbon init script is now called carbon-cache.
- Adding carbon-relay and carbon-aggregator support.
  • Loading branch information...
1 parent 3d2a3c5 commit 14d7100a3478ebe924040f8ae41be4024d3f2a04 @jburnham jburnham committed with vagrant Feb 18, 2012
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# carbon-aggregator init file for starting up the carbon-aggregator daemon
+#
+# chkconfig: - 20 80
+# description: Starts and stops the carbon-aggregator daemon.
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+exec="/usr/bin/carbon-aggregator.py"
+pidfile="/var/run/carbon-aggregator.pid"
+
+CONFIG="/etc/carbon/carbon.conf"
+LOG_DIR="/var/log/carbon-aggregator"
+
+[ -e /etc/sysconfig/carbon-aggregator ] && . /etc/sysconfig/carbon-aggregator
+
+lockfile=/var/lock/subsys/carbon-aggregator
+
+start() {
+ [ -f $CONFIG ] || exit 6
+ [ -x $exec ] || exit 5
+ echo -n $"Starting `basename $exec`: "
+ daemon "$exec --config=$CONFIG --pidfile=$pidfile --logdir=$LOG_DIR start"
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
+}
+
+stop() {
+ echo -n $"Stopping `basename $exec`: "
+ killproc -p $pidfile `basename $exec`
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop
+ start
+}
+
+rh_status() {
+ status -p $pidfile `basename $exec`
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+case "$1" in
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+ restart)
+ $1
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"
+ exit 2
+esac
+exit $?
+
@@ -0,0 +1,4 @@
+# Configuration file for carbon-aggregator
+
+# CONFIG=/etc/carbon/carbon.conf
+# LOG_DIR=/var/log/carbon-aggregator
@@ -9,14 +9,14 @@
. /etc/rc.d/init.d/functions
exec="/usr/bin/carbon-cache.py"
-pidfile="/var/run/carbon.pid"
+pidfile="/var/run/carbon-cache.pid"
CONFIG="/etc/carbon/carbon.conf"
-LOG_DIR="/var/log/carbon"
+LOG_DIR="/var/log/carbon-cache"
-[ -e /etc/sysconfig/carbon ] && . /etc/sysconfig/carbon
+[ -e /etc/sysconfig/carbon-cache ] && . /etc/sysconfig/carbon-cache
-lockfile=/var/lock/subsys/carbon
+lockfile=/var/lock/subsys/carbon-cache
start() {
[ -f $CONFIG ] || exit 6
@@ -30,7 +30,7 @@ start() {
}
stop() {
- echo -n $"Stopping carbon: "
+ echo -n $"Stopping `basename $exec`: "
killproc -p $pidfile `basename $exec`
retval=$?
echo
@@ -0,0 +1,4 @@
+# Configuration file for carbon-cache
+
+# CONFIG=/etc/carbon/carbon.conf
+# LOG_DIR=/var/log/carbon-cache
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# carbon-relay init file for starting up the carbon-relay daemon
+#
+# chkconfig: - 20 80
+# description: Starts and stops the carbon-relay daemon.
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+exec="/usr/bin/carbon-relay.py"
+pidfile="/var/run/carbon-relay.pid"
+
+CONFIG="/etc/carbon/carbon.conf"
+LOG_DIR="/var/log/carbon-relay"
+
+[ -e /etc/sysconfig/carbon-relay ] && . /etc/sysconfig/carbon-relay
+
+lockfile=/var/lock/subsys/carbon-relay
+
+start() {
+ [ -f $CONFIG ] || exit 6
+ [ -x $exec ] || exit 5
+ echo -n $"Starting `basename $exec`: "
+ daemon "$exec --config=$CONFIG --pidfile=$pidfile --logdir=$LOG_DIR start"
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
+}
+
+stop() {
+ echo -n $"Stopping `basename $exec`: "
+ killproc -p $pidfile `basename $exec`
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop
+ start
+}
+
+rh_status() {
+ status -p $pidfile `basename $exec`
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+case "$1" in
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+ restart)
+ $1
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"
+ exit 2
+esac
+exit $?
+
@@ -0,0 +1,4 @@
+# Configuration file for carbon-relay
+
+# CONFIG=/etc/carbon/carbon.conf
+# LOG_DIR=/var/log/carbon-relay
View
@@ -9,7 +9,7 @@
Name: carbon
Version: 0.9.9
-Release: 3
+Release: 4
Summary: Backend data caching and persistence daemon for Graphite
Group: Applications/Internet
License: Apache Software License 2.0
@@ -19,8 +19,12 @@ Packager: Dan Carley <dan.carley@gmail.com>
Source0: http://launchpad.net/graphite/0.9/%{version}/+download/%{name}-%{version}.tar.gz
Patch0: %{name}-setup.patch
Patch1: %{name}-config.patch
-Source1: %{name}.init
-Source2: %{name}.sysconfig
+Source1: %{name}-cache.init
+Source2: %{name}-cache.sysconfig
+Source3: %{name}-relay.init
+Source4: %{name}-relay.sysconfig
+Source5: %{name}-aggregator.init
+Source6: %{name}-aggregator.sysconfig
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
@@ -44,12 +48,18 @@ CFLAGS="$RPM_OPT_FLAGS" %{__python} -c 'import setuptools; execfile("setup.py")'
%{__python} -c 'import setuptools; execfile("setup.py")' install --skip-build --root %{buildroot}
# Create log and var directories
-%{__mkdir_p} %{buildroot}%{_localstatedir}/log/%{name}
+%{__mkdir_p} %{buildroot}%{_localstatedir}/log/%{name}-cache
+%{__mkdir_p} %{buildroot}%{_localstatedir}/log/%{name}-relay
+%{__mkdir_p} %{buildroot}%{_localstatedir}/log/%{name}-aggregator
%{__mkdir_p} %{buildroot}%{_localstatedir}/lib/%{name}
# Install system configuration and init scripts
-%{__install} -Dp -m0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name}
-%{__install} -Dp -m0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
+%{__install} -Dp -m0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name}-cache
+%{__install} -Dp -m0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}-cache
+%{__install} -Dp -m0755 %{SOURCE3} %{buildroot}%{_initrddir}/%{name}-relay
+%{__install} -Dp -m0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/%{name}-relay
+%{__install} -Dp -m0755 %{SOURCE5} %{buildroot}%{_initrddir}/%{name}-aggregator
+%{__install} -Dp -m0644 %{SOURCE6} %{buildroot}%{_sysconfdir}/sysconfig/%{name}-aggregator
# Install default configuration files
%{__mkdir_p} %{buildroot}%{_sysconfdir}/%{name}
@@ -58,10 +68,14 @@ CFLAGS="$RPM_OPT_FLAGS" %{__python} -c 'import setuptools; execfile("setup.py")'
# Create transient files in buildroot for ghosting
%{__mkdir_p} %{buildroot}%{_localstatedir}/lock/subsys
-%{__touch} %{buildroot}%{_localstatedir}/lock/subsys/%{name}
+%{__touch} %{buildroot}%{_localstatedir}/lock/subsys/%{name}-cache
+%{__touch} %{buildroot}%{_localstatedir}/lock/subsys/%{name}-relay
+%{__touch} %{buildroot}%{_localstatedir}/lock/subsys/%{name}-aggregator
%{__mkdir_p} %{buildroot}%{_localstatedir}/run
-%{__touch} %{buildroot}%{_localstatedir}/run/%{name}.pid
+%{__touch} %{buildroot}%{_localstatedir}/run/%{name}-cache.pid
+%{__touch} %{buildroot}%{_localstatedir}/run/%{name}-relay.pid
+%{__touch} %{buildroot}%{_localstatedir}/run/%{name}-aggregator.pid
%pre
%{__getent} group %{name} >/dev/null || %{__groupadd} -r %{name}
@@ -90,18 +104,33 @@ exit 0
%{python_sitelib}/*
/usr/bin/*
-%{_initrddir}/%{name}
+%{_initrddir}/%{name}-cache
+%{_initrddir}/%{name}-relay
+%{_initrddir}/%{name}-aggregator
%config %{_sysconfdir}/%{name}
-%config %{_sysconfdir}/sysconfig/%{name}
+%config %{_sysconfdir}/sysconfig/%{name}-cache
+%config %{_sysconfdir}/sysconfig/%{name}-relay
+%config %{_sysconfdir}/sysconfig/%{name}-aggregator
-%attr(-,%name,%name) %{_localstatedir}/log/%{name}
%attr(-,%name,%name) %{_localstatedir}/lib/%{name}
+%attr(-,%name,%name) %{_localstatedir}/log/%{name}-cache
+%attr(-,%name,%name) %{_localstatedir}/log/%{name}-relay
+%attr(-,%name,%name) %{_localstatedir}/log/%{name}-aggregator
-%ghost %{_localstatedir}/lock/subsys/%{name}
-%ghost %{_localstatedir}/run/%{name}.pid
+%ghost %{_localstatedir}/lock/subsys/%{name}-cache
+%ghost %{_localstatedir}/run/%{name}-cache.pid
+%ghost %{_localstatedir}/lock/subsys/%{name}-relay
+%ghost %{_localstatedir}/run/%{name}-relay.pid
+%ghost %{_localstatedir}/lock/subsys/%{name}-aggregator
+%ghost %{_localstatedir}/run/%{name}-aggregator.pid
%changelog
+* Fri Feb 17 2012 Justin Burnham <justin@jburnham.net> - 0.9.9-4
+- Standardized naming to make things more specific.
+- Old carbon init script is now called carbon-cache.
+- Adding carbon-relay and carbon-aggregator support.
+
* Wed Nov 2 2011 Dan Carley <dan.carley@gmail.com> - 0.9.9-3
- Correct python-twisted-core dependency from 0.8 to 8.0
@@ -1,4 +0,0 @@
-# Configuration file for carbon
-
-# CONFIG=/etc/carbon/carbon.conf
-# LOG_DIR=/var/log/carbon

0 comments on commit 14d7100

Please sign in to comment.