Chiliproject Init script

Posted On // 1 comment
Dear Friend,

This is my init.d script for automatic startup and shutdown of chiliproject (mongrel) using RVM and REE env during system bootup. You can use/modify this script to suite your need for your chiliproject/redmine installation.

#!/usr/bin/env bash
#
# Chilliproject init script written by Animesh Das <jobs4ani at gmail dot com>
#
# chkconfig: - 16 84
# description: Init Script for Chiliproject
#
# processname: mongrel

# source function library
. /etc/rc.d/init.d/functions



# Get network config
. /etc/sysconfig/network

[ "${NETWORKING}" = "no" ] && exit 0

# App Settings
APP_USER=chili
APP_USER_HOME=/home/$APP_USER
APP_NAME=Chiliproject
APP_ROOT=$APP_USER_HOME/chiliproject
APP_PIDFILE=$APP_ROOT/log/chiliproject.pid

# Daemon Settings
DAEMON_USER=$APP_USER
DAEMON_GROUP=$APP_USER
DAEMON_NAME=mongrel
DAEMON_CMD=mongrel_rails
DAEMON_ENV=production
DAEMON_HOME=$APP_ROOT
DAEMON_LOGFILE=$DAEMON_HOME/log/$DAEMON_NAME.log
DAEMON_PIDFILE=$DAEMON_HOME/log/$DAEMON_NAME.pid
DAEMON_LOCKFILE=$DAEMON_HOME/tmp/$DAEMON_NAME.lock
DAEMON_ARGS="-e $DAEMON_ENV -d -p 9090 -l $DAEMON_LOGFILE -P $DAEMON_PIDFILE -c $DAEMON_HOME --user $DAEMON_USER --group $DAEMON_GROUP"

# Set the environment
source $APP_USER_HOME/.rvmrc && [[ -s $APP_USER_HOME/.rvm/scripts/rvm ]] && source $APP_USER_HOME/.rvm/scripts/rvm
if [[ -s "$APP_USER_HOME/.rvm/environments/ree-1.8.7-2011.03" ]]
then
source "$APP_USER_HOME/.rvm/environments/ree-1.8.7-2011.03"
#exec mongrel_rails "$@"
else
echo "ERROR: Missing RVM environment file: '$APP_USER_HOME/.rvm/environments/ree-1.8.7-2011.03'" >&2
exit 1
fi

# Ruby config
MONGREL_BIN=$(type -P $DAEMON_CMD)

start() {
echo -n $"Starting ${APP_NAME}: "

cd $DAEMON_HOME
cat /dev/null > $DAEMON_LOGFILE
sleep 2
daemon $MONGREL_BIN start $DAEMON_ARGS
sleep 2
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
touch $DAEMON_LOCKFILE
fi
echo
}

stop() {
echo -n $"Stopping ${APP_NAME}: "
sleep 2
cd $DAEMON_HOME
killproc -p $DAEMON_PIDFILE
RETVAL=$?
[ $RETVAL -eq 0 ] && /bin/rm -f $DAEMON_LOCKFILE $DAEMON_PIDFILE
echo
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
sleep 3
;;
status)
status -p $DAEMON_PIDFILE $DAEMON_NAME
;;

*)
echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
exit 3
;;
esac

1 comment:

  1. Casino king of conor du Casino & Resort in California
    Venezia Cajun In Cajun Casino & Resort. In Cajun Casino & Resort. In Cajun kirill-kondrashin Casino & Resort. In Cajun Casino 카지노 사이트 & Resort. In Cajun Casino & Resort. The In Cajun Casino & Resort.

    ReplyDelete