Created
January 17, 2017 12:39
-
-
Save nerf/e435ceac72e8c84957be3fd582e87b50 to your computer and use it in GitHub Desktop.
Systemd configuration for ruby God supervisor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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