Redmine is distributed as source and doesn't include any management scripts other than the Ruby ones used to manage Rails. In order to start and stop it automatically on boot on my Fedora 12 workstation, I'm using the following init script.
#!/bin/bash
#
# chkconfig: - 16 84
# description: Start up Redmine
#
# processname: redmine
# config: /etc/sysconfig/redmine
# source function library
. /etc/rc.d/init.d/functions
# Get network config
. /etc/sysconfig/network
[ "${NETWORKING}" = "no" ] && exit 0
# Defaults
DAEMON_HOME=/usr/local/redmine
DAEMON_ARGS="-e production -d"
# Daemon
NAME=redmine
RUBY=$(which ruby)
APP_PIDFILE=$DAEMON_HOME/tmp/pids/server.pid
DAEMON_PIDFILE=/var/run/$NAME.pid
DAEMON_LOCKFILE=/var/lock/subsys/$NAME
start() {
echo -n $"Starting ${NAME}: "
cd $DAEMON_HOME
$RUBY script/server webrick $DAEMON_ARGS
sleep 2
status -p $APP_PIDFILE &> /dev/null && echo_success || echo_failure
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
touch $DAEMON_LOCKFILE
cat $APP_PIDFILE > $DAEMON_PIDFILE
fi
echo
}
stop() {
echo -n $"Shutting down ${NAME}: "
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
;;
status)
status -p $DAEMON_PIDFILE $NAME
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
exit 3
;;
esacOnce you have it in place in /etc/init.d, run the following commands to install it, enable Redmine startup on boot and fire it up.chmod +x /etc/init.d/redmine chkconfig --add redmine chkconfig redmine on /etc/init.d/redmine start
When I run Redmine with /etc/init.d/redmine start all is OK. But
ReplyDeletesudo service redmine start
gives an error:
Starting redmine: /usr/lib/ruby/site_ruby/1.8/rubygems.rb:827:in `report_activate_error': Could not find RubyGem rack (~> 1.0.1) (Gem::LoadError)
What can be wrong?
Hi, I'm not a Ruby or RAILS expert but I'd suggest installing the 'rack' Ruby Gem - you'll notice that the Redmine install instructions list it as a requirement:
ReplyDeletehttp://www.redmine.org/wiki/1/RedmineInstall
Hope that helps.
Hello, thank you! I've rack gem. Your script is working fine when is started from command line. It gives the error when I type: service redmine start. It looks like when runs as service it doesn't have necessary environment variables and cannot find right Ruby gems.
ReplyDeleteI am able to start it on CentOS 5.2 using this but it is not stopping, not sure why. Any idea?
ReplyDeleteEDIT: my bad - all is fine now :) ~ THANKS!
ReplyDeleteI have change a little this script for my thin server instead of webrick.
ReplyDeleteThank for this script.
----RAKESH KUMAR