Skip to content

Instantly share code, notes, and snippets.

@nerf
Created January 17, 2017 12:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nerf/e435ceac72e8c84957be3fd582e87b50 to your computer and use it in GitHub Desktop.
Save nerf/e435ceac72e8c84957be3fd582e87b50 to your computer and use it in GitHub Desktop.
Systemd configuration for ruby God supervisor
[Unit]
Description=God: A process monitoring framework in Ruby
After=network.target
[Service]
Group=_USER_GROUP_
User=_USER_
ExecStart=/usr/local/sbin/god_startup start
ExecStop=/usr/local/sbin/god_startup stop
[Install]
WantedBy=multi-user.target
#!/bin/sh
# set HOME to the setuid user's home, there doesn't seem to be a better, portable way
export HOME="$(eval echo ~$(id -un))"
# Find rbenv to use
if [ -d "/usr/local/rbenv/bin" ]; then
export PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH"
elif [ -d "$HOME/.rbenv/bin" ]; then
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
fi
# master.conf directory
CONF_DIR=/etc/god
GOD_BIN=`rbenv which god`
RUBY_BIN=ruby
RETVAL=0
# Go no further if config directory is missing.
[ -d "$CONF_DIR" ] || exit 0
case "$1" in
start)
exec $RUBY_BIN $GOD_BIN -D -c $CONF_DIR/master.conf
;;
stop)
exec $RUBY_BIN $GOD_BIN quit
;;
*)
echo "Usage: $0 {start|stop}" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment