Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
use a traditional initscript for carbon-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
obfuscurity committed Aug 11, 2014
1 parent ebf047a commit 9c0b498
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 4 deletions.
4 changes: 3 additions & 1 deletion install
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions templates/graphite/conf/carbon.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
81 changes: 81 additions & 0 deletions templates/init.d/carbon-cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/sh

# Initscript for carbon-cache processes
# Jason Dixon <[email protected]>
#
# 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

0 comments on commit 9c0b498

Please sign in to comment.