← Back to team overview

graphite-dev team mailing list archive

Re: [Question #170699]: carbon-cache.py not stopping

 

Question #170699 on Graphite changed:
https://answers.launchpad.net/graphite/+question/170699

    Status: Open => Answered

chrismd proposed the following answer:
Carbon-cache does try to clean out its cache before shutting down. You
can kill -9 it but as you said you will lose datapoints still in memory.
The pidfile is actually supposed to be deleted only once the process
exits but I can see in the code that the stop command explicitly deletes
the file after sending a SIGTERM, so this behavior changed accidentally
from some refactoring.

There are actually trade-offs to both approaches, using an atexit
handler isn't always a reliable way to perform cleanups, especially if
you have an abnormal exit (crash or kill -9). So I'm not 100% sure how
I'm going to handle this going forward yet. What you could do as a
workaround is to read the pid from the pidfile before doing a stop
command, then do something like this:

pid=`cat /opt/graphite/storage/carbon-cache.pid`
echo "Telling carbon-cache to start shutting down..."
/opt/graphite/bin/carbon-cache.py stop
while [ -d /proc/$pid ]
do
  echo "waiting for carbon-cache to shutdown..."
  sleep 5
done
echo "carbon-cache shutdown complete"

-- 
You received this question notification because you are a member of
graphite-dev, which is an answer contact for Graphite.