Last active
August 29, 2015 14:13
-
-
Save mazgi/46bf89ffe9827250f163 to your computer and use it in GitHub Desktop.
RACK App on Gentoo
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
rc_ulimit="-n 65535" | |
rc_need="nginx" | |
RACK_DIR="/var/lib/rack/versions/current" | |
RACK_BUNDLE_EXEC="/usr/local/bin/bundle" | |
RACK_RB="/var/lib/rack/versions/current/config/unicorn.rb" |
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
#!/sbin/runscript | |
# Copyright 1999-2014 Gentoo Foundation | |
# Distributed under the terms of the GNU General Public License v2 | |
# $Header: $ | |
description="A RACK daemon" | |
RACK_ENVIRONMENT="${RACK_ENVIRONMENT:-production}" | |
RACK_USER="${RACK_USER:-rack}" | |
RACK_GROUP="${RACK_GROUP:-rack}" | |
RACK_NAME="${SVCNAME##*.}" | |
if [ -n "${RACK_NAME}" -a "${SVCNAME}" != "rack" ]; then | |
description="${description} for ${RACK_NAME}" | |
RACK_PID_FILE="/var/run/rack.${RACK_NAME}.pid" | |
RACK_RB_DEFAULT="/etc/rack/${RACK_NAME}.rb" | |
else | |
RACK_PID_FILE="/var/run/rack.pid" | |
RACK_RB_DEFAULT="/etc/rack/unicorn.rb" | |
fi | |
RACK_DIR="${RACK_DIR:-/var/lib/rack}" | |
RACK_RB="${RACK_RB:-${RACK_RB_DEFAULT}}" | |
RACK_WORKER_PROCESSES="${RACK_WORKER_PROCESSES:-4}" | |
RACK_BUNDLE_EXEC="${RACK_BUNDLE_EXEC:-/usr/local/bin/bundle}" | |
LD_PRELOAD_OPTS="" | |
if [ -f "/usr/lib64/libjemalloc.so" ]; then | |
LD_PRELOAD_OPTS="/usr/lib64/libjemalloc.so" | |
fi | |
depend() { | |
need net | |
} | |
start() { | |
ebegin "Starting ${SVCNAME}" | |
start-stop-daemon \ | |
--start \ | |
--chdir "${RACK_DIR}" \ | |
--user "${RACK_USER}" \ | |
--background \ | |
--make-pidfile --pidfile "${RACK_PID_FILE}" \ | |
--env PATH="${PATH}:$(dirname ${RACK_BUNDLE_EXEC})" \ | |
--env LD_PRELOAD="${LD_PRELOAD_OPTS}" \ | |
--env RACK_PID_FILE="${RACK_PID_FILE}" \ | |
--exec "${RACK_BUNDLE_EXEC}" \ | |
-- exec unicorn_rails -c "${RACK_RB}" -E "${RACK_ENVIRONMENT}" | |
eend $? | |
} | |
stop() { | |
ebegin "Stopping ${SVCNAME}" | |
start-stop-daemon --stop --pidfile "${RACK_PID_FILE}" | |
eend $? | |
} |
Author
mazgi
commented
Jan 21, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment