Project

General

Profile

0001-fixes-1472-make-init-script-passenger-aware-redhat.patch

Mikael Fridh, 01/26/2012 09:11 AM

View differences:

extras/spec/foreman.init
19 19
FOREMAN_HOME=${FOREMAN_HOME:-/usr/share/foreman}
20 20
FOREMAN_ENV=${FOREMAN_ENV:-production}
21 21
FOREMAN_PID=${FOREMAN_PID:-${FOREMAN_HOME}/tmp/pids/server.pid}
22
FOREMAN_USE_PASSENGER=${FOREMAN_USE_PASSENGER:-0}
22 23

  
23 24
start() {
24 25
    echo -n $"Starting $prog: "
......
49 50
    return $RETVAL
50 51
}
51 52

  
53
railsrestart() {
54
    echo -n $"Restarting foreman rails app: "
55
    touch "${FOREMAN_HOME}/tmp/restart.txt"
56
    RETVAL=$?
57
    if [ $RETVAL = 0 ]
58
    then
59
        echo_success
60
    else
61
        echo_failure
62
    fi
63

  
64
    echo
65
    return $RETVAL
66
}
67

  
52 68
# See how we were called.
53 69
case "$1" in
54
    start)
55
        start
70
    start|stop)
71
        if [ ${FOREMAN_USE_PASSENGER} = 1 ]
72
        then
73
            echo -n "Foreman is running under passenger"
74
            echo_passed
75
            echo
76
        else
77
            $1
78
        fi
79
        RETVAL=$?
56 80
    ;;
57
    stop)
58
        stop
81
    restart)
82
        if [ ${FOREMAN_USE_PASSENGER} = 1 ]
83
        then
84
            railsrestart
85
            RETVAL=$?
86
        else
87
            stop
88
            start
89
            RETVAL?$?
90
        fi
59 91
    ;;
60 92
    status)
61 93
        echo -n "Foreman"
62
        status -p $FOREMAN_PID
94
        if [ ${FOREMAN_USE_PASSENGER} = 1 ]
95
        then
96
            echo -n " is running under passenger"
97
            echo_passed
98
            echo
99
        else
100
		status -p $FOREMAN_PID
101
        fi
63 102
        RETVAL=$?
64 103
    ;;
65
    restart)
66
        stop
67
        start
68
    ;;
69 104
    condrestart)
70 105
        if [ -f ${FOREMAN_HOME}/tmp/pids/server.pid ]; then
71
            stop
72
            start
106
            restart
73 107
            RETVAL=$?
74 108
        fi
75 109
        ;;
extras/spec/foreman.sysconfig
10 10

  
11 11
# the rails environment in which foreman runs
12 12
#FOREMAN_ENV=production
13

  
14
# if we're using passenger or not
15
# if set to 1, init script will do a railsrestart on 'restart' and will refuse
16
# 'start' and 'stop' completely and remind the operator that passenger is in 
17
# use.
18
#FOREMAN_USE_PASSENGER=0
13
-