~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerheadd

  • Committer: Robey Pointer
  • Date: 2006-12-20 03:05:27 UTC
  • Revision ID: robey@lag.net-20061220030527-h9fh8fztifgne8q7
slowly moving the branch-specific stuff into a common structure...
the changes cache is now its own class (ChangeCache) like TextIndex, and
both are fields in History.  almost all of the cache rebuilding logic, etc,
has been moved there and out of __init__.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
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)
8
 
### END INIT INFO
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
 
 
28
 
LOG_FOLDER=/var/log/loggerhead
29
 
LOG_FILE=$LOG_FOLDER/loggerheadd.log
30
 
URL_PREFIX=/loggerhead
31
 
PORT=8080
32
 
 
33
 
#please specify the base directory to serve:
34
 
BZRROOT=/bzrroot
35
 
 
36
 
# 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
 
 
39
 
 
40
 
#
41
 
# main part
42
 
#
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
 
case "$1" in
96
 
    start)
97
 
        start_loggerhead
98
 
    ;;
99
 
    stop)
100
 
        stop_loggerhead
101
 
    ;;
102
 
    status)
103
 
        loggerhead_status
104
 
    ;;
105
 
    restart)
106
 
        stop_loggerhead
107
 
        start_loggerhead
108
 
    ;;
109
 
    *)
110
 
        echo "Usage: loggerheadd { start | stop | status | restart }"
111
 
        exit 1
112
 
esac