I'm trying to set up Graphite on my server. I can start the Carbon Cache daemon no problem with sudo /opt/graphite/bin/carbon-cache.py start
, but I'm struggling to run it as a Systemd unit.
Here's what I have in my service file, graphite.service
:
[Unit]
Description=Carbon for Graphite
[Service]
ExecStart=/opt/graphite/bin/carbon-cache.py start
[Install]
WantedBy=multi-user.target
But when I start the unit I get the following status:
$ systemctl status graphite.service
* graphite.service - Carbon for Graphite
Loaded: loaded (/etc/systemd/system/graphite.service; enabled)
Active: inactive (dead) since Fri 2014-06-13 18:44:11 UTC; 2s ago
Process: 4525 ExecStart=/opt/graphite/bin/carbon-cache.py start (code=exited, status=0/SUCCESS)
Main PID: 4525 (code=exited, status=0/SUCCESS)
Jun 13 18:44:11 MEADOW systemd[1]: Started Carbon for Graphite.
Journalctl yields no more information.
How should I interpret and debug units with a status of "inactive (dead)…(code=exited, status=0/SUCCESS)"? I've seen failed units before, but this one is successfully loaded yet not running and I don't know what that means.
Best Answer
Per jasonwryan's comment, while the default
Type=simple
works for many Systemd service files, it does not work when the script inExecStart
launches another process and completes, as is the case with graphite's carbon-cache.py. In these cases you need to explicitly specifyType=forking
in the[Service]
section so that Systemd knows to look at the spawned process rather than the initial one.As explained in
man systemd.service
:Graphite-Specific Answer
While the above solved my Systemd issue, I quickly ran into graphite-specific issues (with Twisted) and ended up going back to the default
Type
.Graphite < 0.9.12
In previous versions of Graphite one can only avoid forking by using the
--debug
option:Graphite >= 0.9.13
In this pull request a
--no-daemon
option was merged: