Skip to content

Instantly share code, notes, and snippets.

@acdha
Last active March 20, 2022 02:02
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save acdha/1506392 to your computer and use it in GitHub Desktop.
Save acdha/1506392 to your computer and use it in GitHub Desktop.
Upstart config for Graphite's carbon-cache daemon
#!/etc/init/carbon-cache.conf
description "Carbon server"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
umask 022
expect fork
respawn
pre-start script
test -d /opt/graphite || { stop; exit 0; }
end script
chdir /opt/graphite
# Note the use of a wrapper so we can activate our virtualenv:
exec start-stop-daemon --oknodo --chdir /opt/graphite --user graphite --chuid graphite --pidfile /opt/graphite/storage/carbon-cache-a.pid --name carbon-cache --startas /opt/graphite/bin/run-carbon-cache.sh --start start
#!/bin/sh
set -e
HOME=/opt/graphite
. /opt/graphite/.virtualenv/bin/activate
. /opt/graphite/.virtualenv/bin/postactivate
exec /opt/graphite/bin/carbon-cache.py "$@"
@jokull
Copy link

jokull commented Aug 8, 2012

Thanks. Annoying that software authors are still building daemonization into their executables. This helped : )

@magicrobotmonkey
Copy link

I'm having trouble with this as strace is telling me there's 3 forks, which upstart can't handle and gets into a bad place

@dokipen
Copy link

dokipen commented Jul 22, 2013

Use --debug to keep carbon-cache in the foreground and you will have no issues.

@bryanlarsen
Copy link

This script didn't work very well for us; it tends to leave pid files around and refuses to restart. We've had better luck with this one: https://github.com/captnswing/chef-graphite/blob/master/templates/default/carbon-cache-upstart.erb

@acdha
Copy link
Author

acdha commented May 27, 2014

I'm looking to deprecate this version in favor of @dbeckham's better version which avoids some of the craziness by running twisted with --nodaemon rather than having to fight it:

https://gist.github.com/dbeckham/8057390

(see graphite-project/carbon#144 for the actual request for first-class support in carbon-cache.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment