Created
April 3, 2013 14:51
-
-
Save chenha0/5301883 to your computer and use it in GitHub Desktop.
Redmine daemonize script - using webrick as service. Original from http://www.redmine.org/boards/1/topics/9334
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
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: redmine | |
# Required-Start: $local_fs $remote_fs $network | |
# Required-Stop: $local_fs $remote_fs $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: redmine webrick | |
# Description: redmine webrick server autostart-script | |
### END INIT INFO | |
. /lib/lsb/init-functions | |
# Modify it to your configuration | |
DIR=/srv/redmine/ | |
# Start Redmine in daemon mode. | |
start(){ | |
log_daemon_msg "Starting Redmine WebRick" | |
cd $DIR | |
log_progress_msg | |
ruby script/server -d -e production &> /dev/null | |
log_progress_msg | |
log_end_msg 0 | |
} | |
# Stop Redmine daemon | |
stop(){ | |
log_daemon_msg "Stopping Redmine WebRick" | |
RUBYPID=`ps aux | grep "ruby script/server -d -e production" | grep -v grep | awk '{print $2}'` | |
log_progress_msg | |
if [ "x$RUBYPID" != "x" ]; then | |
kill -2 $RUBYPID | |
fi | |
log_end_msg 0 | |
} | |
# Check if Redmine is running | |
status(){ | |
RUBYPID=`ps aux | grep "ruby script/server -d -e production" | grep -v grep | awk '{print $2}'` | |
if [ "x$RUBYPID" = "x" ]; then | |
echo "* Redmine is not running" | |
else | |
echo "* Redmine is running" | |
fi | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart|force-reload) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|force-reload|status}" | |
exit 1 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment