Skip to content

Instantly share code, notes, and snippets.

@deogracia
Created April 24, 2015 13:16
Show Gist options
  • Save deogracia/5cc1f8c8ebfab488df70 to your computer and use it in GitHub Desktop.
Save deogracia/5cc1f8c8ebfab488df70 to your computer and use it in GitHub Desktop.
Sample and incomplete init.d script using rvm wrapper
#! /bin/sh
### BEGIN INIT INFO
# Provides: redmine-unicorn
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Init Redmine with Unicorn
# Description: Start Redmine Unicorn.
# This script is not part of a package.
### END INIT INFO
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Redmine Unicorn"
NAME=redmine-unicorn
WRAPPER="ext_2.0.0_bundle"
DAEMON="/redmine/.rvm/bin/$WRAPPER"
DAEMON_ARGS="exec unicorn_rails -p 5000 -D -c /redmine/config/unicorn.rb -E production"
PIDFILE=/redmine/redmine-unicorn/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
UNICORN_USER="redmine"
UNICORN_GROUP="redmine"
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --chuid $UNICORN_USER:$UNICORN_GROUP --chdir $APP_ROOT --exec $DAEMON --test > /dev/null \
|| return 1
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment