From 9c0b498bd0e45abbd5069ac980a83329fe6d1b24 Mon Sep 17 00:00:00 2001 From: obfuscurity Date: Sun, 10 Aug 2014 22:27:31 -0400 Subject: [PATCH] use a traditional initscript for carbon-cache --- install | 4 +- templates/graphite/conf/carbon.conf | 8 +-- templates/init.d/carbon-cache | 81 +++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 templates/init.d/carbon-cache diff --git a/install b/install index 229e6b5..9cf6300 100755 --- a/install +++ b/install @@ -46,6 +46,7 @@ cp ${SYNTHESIZE_HOME}/templates/graphite/conf/* ${GRAPHITE_CONF}/ cp ${SYNTHESIZE_HOME}/templates/collectd/collectd.conf /etc/collectd/ cp ${SYNTHESIZE_HOME}/templates/apache/graphite.conf /etc/apache2/sites-available/ cp ${SYNTHESIZE_HOME}/templates/init/* /etc/init/ +cp ${SYNTHESIZE_HOME}/templates/init.d/* /etc/init.d/ # Setup the correct Apache site and modules a2dissite 000-default @@ -70,9 +71,10 @@ chown www-data:carbon ${GRAPHITE_STORAGE} chown -R carbon ${GRAPHITE_STORAGE}/whisper mkdir ${GRAPHITE_STORAGE}/log/apache2 chown -R www-data ${GRAPHITE_STORAGE}/log +chmod +x /etc/init.d/carbon-cache # Start our processes -service carbon start +service carbon-cache start service memcached start service collectd start service apache2 start diff --git a/templates/graphite/conf/carbon.conf b/templates/graphite/conf/carbon.conf index 80c5817..9713c7c 100644 --- a/templates/graphite/conf/carbon.conf +++ b/templates/graphite/conf/carbon.conf @@ -7,15 +7,17 @@ WHISPER_FALLOCATE_CREATE = True MAX_CREATES_PER_MINUTE = 100 MAX_UPDATES_PER_SECOND = 1000 LINE_RECEIVER_INTERFACE = 0.0.0.0 -LINE_RECEIVER_PORT = 2003 PICKLE_RECEIVER_INTERFACE = 0.0.0.0 -PICKLE_RECEIVER_PORT = 2004 USE_INSECURE_UNPICKLER = False CACHE_QUERY_INTERFACE = 0.0.0.0 -CACHE_QUERY_PORT = 7002 LOG_CACHE_HITS = False LOG_CACHE_QUEUE_SORTS = True LOG_LISTENER_CONNECTIONS = True LOG_UPDATES = False ENABLE_LOGROTATION = True WHISPER_AUTOFLUSH = False + +[cache:1] +LINE_RECEIVER_PORT = 2003 +PICKLE_RECEIVER_PORT = 2004 +CACHE_QUERY_PORT = 7002 diff --git a/templates/init.d/carbon-cache b/templates/init.d/carbon-cache new file mode 100644 index 0000000..9d3c2d9 --- /dev/null +++ b/templates/init.d/carbon-cache @@ -0,0 +1,81 @@ +#!/bin/sh + +# Initscript for carbon-cache processes +# Jason Dixon +# +# You must set the variables below. The +# INSTANCES variable should be set to the +# number of carbon-cache instances you have +# configured in your carbon.conf. Note that +# they must be numerically indexed from 1. +# (e.g. [cache:1], [cache:2], [cache:3] + +PID_DIR=/opt/graphite/storage +DAEMON=/opt/graphite/bin/carbon-cache.py +NAME=carbon-cache +INSTANCES=1 + +set -e + +test -x $DAEMON || exit 0 + +case "$1" in + + start) + for INSTANCE in $(seq 1 $INSTANCES); do + echo -n "Starting ${NAME}-${INSTANCE}: " + if start-stop-daemon --start --quiet --pidfile "${NAME}-${INSTANCE}.pid" --exec $DAEMON start 1>/dev/null -- --instance=${INSTANCE} + then + echo "succeeded" + else + echo "failed" + fi + done + ${0} status + ;; + + stop) + for INSTANCE in $(seq 1 $INSTANCES); do + echo -n "Stopping ${NAME}-${INSTANCE}: " + $DAEMON stop --instance=${INSTANCE} 1>/dev/null + echo "stopped" + done + exit 0 + ;; + + restart) + ${0} stop + ${0} start + ;; + + status) + for INSTANCE in $(seq 1 $INSTANCES); do + if [ -f "${PID_DIR}/${NAME}-${INSTANCE}.pid" ]; then + PID=`cat "${PID_DIR}/${NAME}-${INSTANCE}.pid"` + + echo -n "${NAME}-${INSTANCE} (pid: $PID): " + if ps -p $PID >/dev/null; then + echo "running" + else + echo "failed" + fi + else + echo "${NAME}-${INSTANCE} not running" + fi + done + for INSTANCE in $(seq 1 $INSTANCES); do + if [ ! -f "${PID_DIR}/${NAME}-${INSTANCE}.pid" ]; then + exit 1 + fi + done + exit 0 + ;; + + *) + echo "Usage: /etc/init.d/${NAME} {start|stop|restart|status}" >%2 + exit 1 + ;; + +esac + +exit 0