How to configure OpenTSDB (or any process) as a systemd service in CentOS 7? | MyThinkPond

centos_logoCentOS 7 uses Systemd for managing services (prior to CentOS 7 it was using upstart-init.d to manage the services).

Step-1: Create CentOS 7 Service file: vim /usr/lib/systemd/system/opentsdb.service



[Unit]
Description=OpenTSDB Service
After=network.target hbase.service

[Service]
Type=forking
PrivateTmp=yes
ExecStart=/usr/share/opentsdb/etc/init.d/opentsdb start
ExecStop=/usr/share/opentsdb/etc/init.d/opentsdb stop
Restart=on-abort

[Install]
WantedBy=multi-user.target

Step-2: Let’s test the start and stop of this new OpenTSDB service



$ sudo systemctl start opentsdb
# If it starts up good, you should see the website when you goto http://<servername>:4242/
ps -leaf | grep "tsdb"
# shows you something similar then you can add it as a service to auto-start
sudo systemctl enable opentsdb

Step-3: (optional) Reboot node and make sure that the service starts up accordingly after a reboot.

If you want to learn more about the available options under systemd refer to this link here.

Some useful options to learn are: ExecStartPre=, ExecStartPost=

Some other examples for including options like the ones below can be seen here:


WorkingDirectory=/usr/share/grafana
ExecStart=/usr/sbin/grafana-server                                \
                            --config=${CONF_FILE}                 \
                            --pidfile=${PID_FILE}                 \
                            cfg:default.paths.logs=${LOG_DIR}     \
                            cfg:default.paths.data=${DATA_DIR}    \
                            cfg:default.paths.plugins=${PLUGINS_DIR}

Additionally here is one more resource.

Cheers.

Venkatt Guhesan avatar
About Venkatt Guhesan
Enterprise Software Architect currently working at DataDirect Networks developing a highly scalable monitoring solution called DDN Insight. My passions include all things Open Source including Linux (CentOS, Red Hat, Gentoo, Open Stack, Docker & Ubuntu), embedded ARM processors and microcontrollers (Arduino, UDOO, Cubieboard, BeagleBoard, OnionIO, TI's Zigbee). Coming from an Electrical and Computer Engineering background, working in developing and designing enterprise - distributed, highly scalable software requires a unique set of software skills with a good understanding of the hardware. This makes his work challenging and interesting. In his free time, he spends his time with his family and two children. He also enjoys researching on topics including - world ancient history and yoga. Visit the 'About' section for more details.
comments powered by Disqus