~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerheadd

  • Committer: Marius Kruger
  • Date: 2008-10-02 21:12:58 UTC
  • mto: This revision was merged to the branch mainline in revision 240.
  • Revision ID: amanic@gmail.com-20081002211258-n28j8aa8fmp3u5ck
Add installation instructions for loggerheadd to README.txt and changed ubuntu -> Ubuntu for consistancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
### BEGIN INIT INFO
3
 
# Required-Start:       $local_fs $remote_fs $network
4
 
# Default-Start:        3 5
5
 
# Default-Stop:         0 1 2 6
6
 
# Short-Description:    Loggerhead
7
 
# Description:          Manage Loggerhead (a web viewer for projects in bazaar)
 
3
# Required-Start:               $local_fs $remote_fs $network
 
4
# Default-Start:                3 5
 
5
# Default-Stop:                 0 1 2 6
 
6
# Short-Description:            Loggerhead
 
7
# Description:                  Manage Loggerhead (a web viewer for projects in bazaar)
8
8
### END INIT INFO
9
9
 
10
 
 
11
 
#
12
 
# Configure this please:
13
 
# (Please stop loggerhead before changing the configuration, otherwise this
14
 
#   script might not be able to kill loggerhead)
15
 
#
16
 
 
17
 
LHUSER=loggerhead
18
 
 
19
 
if [ `whoami` = "$LHUSER" ]; then
20
 
    SUDO=""
21
 
else
22
 
    SUDO="sudo -H -u $LHUSER"
23
 
fi
24
 
 
25
 
# If serve-branches is not in your path, you will need to specify the full path:
26
 
SERVE_BRANCHES_CMD=serve-branches
27
 
 
 
10
# Configure this please: #
 
11
LOGGERHEAD_PATH=/opt/loggerhead
28
12
LOG_FOLDER=/var/log/loggerhead
29
13
LOG_FILE=$LOG_FOLDER/loggerheadd.log
30
 
URL_PREFIX=/loggerhead
 
14
PREFIX=/loggerhead
31
15
PORT=8080
32
16
 
33
 
#please specify the base directory to serve:
34
 
BZRROOT=/bzrroot
35
 
 
36
17
# You can add additional options to serve-branches here:
37
 
START_CMD="$SERVE_BRANCHES_CMD --prefix=$URL_PREFIX --log-folder=$LOG_FOLDER --port=$PORT $BZRROOT"
38
 
 
 
18
START_CMD="$LOGGERHEAD_PATH/serve-branches --prefix=$PREFIX --log-folder=$LOG_FOLDER --port=$PORT /var/lib/gforge/bzrroot/"
39
19
 
40
20
#
41
21
# main part
42
22
#
43
 
 
44
 
loggerhead_process(){
45
 
    $SUDO pgrep -fl "$START_CMD"
46
 
}
47
 
 
48
 
loggerhead_status(){
49
 
    proccess=`loggerhead_process`
50
 
    #echo "$proccess"
51
 
    listening=`netstat -nl |grep -e ":$PORT "`
52
 
    #echo "$listening"
53
 
    if [ -z "$proccess" ]; then
54
 
        echo "Loggerhead is *not* running."
55
 
    else
56
 
        echo "Loggerhead is running."
57
 
        if [ -z "$listening" ]; then
58
 
            echo "This server is *not* listening on port $PORT."
59
 
        else
60
 
            echo "This server is listening on port $PORT."
61
 
        fi
62
 
    fi
63
 
}
64
 
 
65
 
start_loggerhead(){
66
 
    echo "Starting loggerhead.   (See $LOG_FOLDER for details.)"
67
 
 
68
 
    # make sure the log folder is created
69
 
    if [ ! -d $LOG_FOLDER ]
70
 
    then
71
 
        $SUDO mkdir -p $LOG_FOLDER
72
 
    fi
73
 
    echo "" > $LOG_FILE
74
 
    $SUDO python $START_CMD > $LOG_FILE 2>&1 &
75
 
 
76
 
    #wait a little while of some logging to appear
77
 
    log=""
78
 
    for i in $(seq 1 3 30); do
79
 
        log=`cat $LOG_FILE`
80
 
        if [ -n "$log" ]; then
81
 
            break
82
 
        fi
83
 
        sleep 0.3
84
 
    done
85
 
    tail $LOG_FILE
86
 
    loggerhead_status
87
 
}
88
 
 
89
 
stop_loggerhead(){
90
 
    echo "Stopping loggerhead."
91
 
    $SUDO pkill -f "$START_CMD"
92
 
    loggerhead_status
93
 
}
94
 
 
95
23
case "$1" in
96
24
    start)
97
 
        start_loggerhead
 
25
        python $START_CMD > $LOG_FILE 2>&1 &
 
26
    echo "Started loggerhead.   (See $LOG_FOLDER for details.)"
98
27
    ;;
99
28
    stop)
100
 
        stop_loggerhead
 
29
    pkill -f "$START_CMD"
101
30
    ;;
102
31
    status)
103
 
        loggerhead_status
104
 
    ;;
105
 
    restart)
106
 
        stop_loggerhead
107
 
        start_loggerhead
108
 
    ;;
 
32
        proccess=`pgrep -fl "$START_CMD"`
 
33
        echo "$proccess"
 
34
        netstat -anp |grep -e ":$PORT"
 
35
        if [ -z "$proccess" ]; then
 
36
        echo "Loggerhead is not running."
 
37
    else
 
38
        echo "Loggerhead is running."
 
39
        fi
 
40
        ;;
 
41
 
109
42
    *)
110
 
        echo "Usage: loggerheadd { start | stop | status | restart }"
111
 
        exit 1
 
43
        echo "Usage: loggerheadd { start | stop | status }"
 
44
    exit 1
112
45
esac