Created
June 14, 2018 11:14
-
-
Save MichaelMayorov/5a5e4c349c741618fb0c9ed3caea5d7d to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing. | |
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then | |
set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script | |
fi | |
### BEGIN INIT INFO | |
# Provides: redmine-fcgi | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Redmine fcgi daemon | |
# Description: Layer between nginx and redmine fcgi executor | |
### END INIT INFO | |
# Author: Mikhail Mayorov <[email protected]> | |
DESC="Redmine FCGI daemon" | |
DAEMON=/usr/bin/spawn-fcgi | |
NAME=redmine-fcgi | |
USER=root | |
PIDFILE=/var/run/redmine-fcgi.pid | |
LOGFILE=/var/log/redmine.log | |
HELPER=/usr/bin/daemon | |
HELPER_ARGS="--name=$NAME --output=$LOGFILE --pidfile=$PIDFILE --user=$USER -D /usr/share/redmine" | |
ARGS=`cat <<EOF | |
-n -s /tmp/redmine-default-fcgi.socket -M 640 -u www-data -- \ | |
/usr/bin/multiwatch -f 2 /usr/share/redmine/public/dispatch.fcgi | |
EOF | |
` | |
do_start_cmd() | |
{ | |
# Return | |
# 0 if daemon has been started | |
# 1 if daemon was already running | |
# 2 if daemon could not be started | |
export RAILS_RELATIVE_URL_ROOT="/" | |
export X_DEBIAN_SITEID="default" | |
export RAILS_ENV="production" | |
$HELPER $HELPER_ARGS --running && return 1 | |
$HELPER $HELPER_ARGS -- $DAEMON $ARGS || return 2 | |
return 0 | |
} | |
do_stop_cmd() | |
{ | |
# Return | |
# 0 if daemon has been stopped | |
# 1 if daemon was already stopped | |
# 2 if daemon could not be stopped | |
# other if a failure occurred | |
$HELPER $HELPER_ARGS --running || return 1 | |
$HELPER $HELPER_ARGS --stop || return 2 | |
# wait for the process to really terminate | |
for n in 1 2 3 4 5; do | |
sleep 1 | |
$HELPER $HELPER_ARGS --running || break | |
done | |
$HELPER $HELPER_ARGS --running || return 0 | |
return 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment