Skip to content

Instantly share code, notes, and snippets.

@johncalvinyoung
Forked from 0h546f6f78696342756e4e59/gist:2636887
Last active December 15, 2015 19:59
Show Gist options
  • Save johncalvinyoung/5315288 to your computer and use it in GitHub Desktop.
Save johncalvinyoung/5315288 to your computer and use it in GitHub Desktop.
Gentoo startup script for unicorn
#!/sbin/runscript
# unicorn init script for Gentoo Linux
APP_ROOT=/var/www/apps/your_app
RAILS_ROOT=$APP_ROOT/current
USER=your_user
extra_commands="reload"
depend() {
need net
}
start() {
ebegin "Starting unicorn server"
start-stop-daemon --start \
--chdir "${RAILS_ROOT}" \
--user "${USER}" \
--pidfile "${RAILS_ROOT}/tmp/pids/unicorn.pid" \
--exec bundle -- exec unicorn_rails -c "${APP_ROOT}/shared/config/unicorn.rb" -E production -D
eend $?
}
stop() {
ebegin "Stopping unicorn server"
start-stop-daemon --stop \
--chdir "${RAILS_ROOT}" \
--user "${USER}" \
--pidfile "${RAILS_ROOT}/tmp/pids/unicorn.pid"
eend $?
}
reload() {
ebegin "Seamlessly restarting unicorn server"
kill -USR2 `cat "${RAILS_ROOT}/tmp/pids/unicorn.pid"`
eend $?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment