/opt/graphite/bin/carbon-cache.py start systemd service?

Asked by iodisciple

Hi all,

To get Carbon running I've used the /opt/graphite/bin/carbon-cache.py start command. No problem here. I would like though to get it in a systemd unit file. I tried the below, using another template, but this fails. What should be a proper systemd unit file?

/etc/systemd/system/carbon.service:

[Unit]
Description=carbon daemon
After=network.target

[Service]
User=root
Group=www-data
WorkingDirectory=/opt/graphite/bin
ExecStart=/opt/graphite/bin/carbon-cache.py start

[Install]
WantedBy=multi-user.target

Question information

Language:
English Edit question
Status:
Solved
For:
Graphite Edit question
Assignee:
No assignee Edit question
Solved by:
Piotr Popieluch
Solved:
Last query:
Last reply:
Revision history for this message
Yousef F (yousef.fattal) said :
#1

Hi

assuming the purpose is to get it as a service i usually use

cp /graphite/examples/init.d/carbon-cache /etc/init.d/
chmod 755 /etc/init.d/carbon-cache; chkconfig carbon-cache on; service carbon-cache start

Not sure if that might help but just wanted to share it with you.

Revision history for this message
iodisciple (iodisciple) said :
#2

Hi Yousef,

Thank you for your answer, but I believe this does not work on a systemd system right?

The purpose is indeed getting it running as a service.

Kind regards,
iodisiciple

Revision history for this message
iodisciple (iodisciple) said :
#3

Hi again,

Does anybody have a valid systemd unit file to get carbon-cache started and enabled via systemd?

Thanks and kind regards,
iodisicple

Revision history for this message
Best Piotr Popieluch (piotr1212) said :
#4

There are systemd unit files in the RPM package, see for sources here:
https://src.fedoraproject.org/rpms/python-carbon/tree/master

Revision history for this message
iodisciple (iodisciple) said :
#5

Many thanks, this did the trick:

[Unit]
Description=Graphite Carbon Cache
After=network.target

[Service]
Type=forking
StandardOutput=syslog
StandardError=syslog
ExecStart=/opt/graphite/bin/carbon-cache.py --config=/opt/graphite/conf/carbon.conf --pidfile=/var/run/carbon-cache.pid start
ExecReload=/bin/kill -USR1 $MAINPID
PIDFile=/var/run/carbon-cache.pid

[Install]
WantedBy=multi-user.target

Revision history for this message
iodisciple (iodisciple) said :
#6

Thanks Piotr Popieluch, that solved my question.