Skip to content

systemd service using rbenv

penguinpowernz edited this page Oct 20, 2014 · 1 revision

We needed to get this working with a systemwide rbenv install as a systemd service. This file did the trick:

# /lib/systemd/system/redis-alerting.service

[Unit]
Description=Redis Alerting

[Service]
Environment="RBENV_VERSION=2.1.3"
ExecStart=/usr/local/rbenv/shims/redis-alerting run -- -c /etc/redis-alerting.yml
ExecStop=/usr/local/rbenv/shims/redis-alerting stop

It can then be used like so:

systemctl start redis-alerting.service
systemctl stop redis-alerting.service
systemctl restart redis-alerting.service
systemctl enable redis-alerting.service
systemctl disable redis-alerting.service

rbenv was installed to /usr/local/rbenv following this guide with the exception that the environment variables were placed at the end of /etc/profile like so:

# /etc/profile

#...SNIP...

export RBENV_ROOT=/usr/local/rbenv
export PATH="$RBENV_ROOT/bin:$PATH"
export RBENV_VERSION=2.1.3
eval "$(rbenv init -)"

Clone this wiki locally