Redmine - slopjong/w GitHub Wiki
redmine.service (to be put in /lib/systemd/system/)
[Unit] Description=Redmine webserver After=network.target
[Service]
User=redmine
ExecStart=/usr/bin/ruby-1.8 /var/lib/redmine/script/server webrick -e sqlite3
ExecStop=/bin/kill -INT $MAINPID[Install]
WantedBy=multi-user.target
redmine.rc (to be put in /etc/rc.d)
#!/bin/bash
daemon_name=redmine
daemon_command=“ruby-1.8 /var/lib/redmine/script/server webrick -d -e sqlite3”. /etc/rc.conf
. /etc/rc.d/functionsget_pid() {
pgrep -u redmine -f “${daemon_command}”
}case “$1” in
PID=$(get_pid) if [ -z “$PID” ]; then [ -f /var/run/$daemon_name.pid ] && rm -f /var/run/$daemon_name.pid
start)
stat_busy “Starting $daemon_name daemon”stop) stat_busy “Stopping $daemon_name daemon” PID=$(get_pid)
- RUN
su -s ‘/bin/sh’ redmine -c “${daemon_command} &>/dev/null”
#
if [ $? -gt 0 ]; then
stat_fail
exit 1
else
echo $(get_pid) > /var/run/$daemon_name.pid
add_daemon $daemon_name
stat_done
fi
else
stat_fail
exit 1
fi
;;restart) $0 stop sleep 1 $0 start ;; status) stat_busy “Checking $daemon_name status”; ck_status $daemon_name ;; *) echo “usage: $0 {start|stop|restart|status}”
- KILL
[ ! -z “$PID” ] && kill -INT $PID &> /dev/null
#
if [ $? -gt 0 ]; then
stat_fail
exit 1
else
rm -f /var/run/$daemon_name.pid &> /dev/null
rm_daemon $daemon_name
stat_done
fi
;;esac
exit 0