File: httplib

package info (click to toggle)
darcs 2.18.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,960 kB
  • sloc: haskell: 47,748; sh: 13,466; ansic: 447; perl: 134; makefile: 8
file content (27 lines) | stat: -rw-r--r-- 733 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
serve_http() {
    lightpid=$((10000 + $$ % 30000))
    cat > light.conf <<EOF
    server.document-root       = "$PWD"
    server.errorlog            = "$PWD/error.log"
    server.port                = $lightpid
    server.bind                = "localhost"
    server.pid-file            = "$PWD/light.pid"
    index-file.names           = ()
EOF
    trap "finish_http \"$PWD\"" EXIT
    PATH=${PATH}:/sbin:/usr/sbin
    lighttpd -f light.conf || exit 200
    ps `cat light.pid` > /dev/null 2>&1 || exit 200
    baseurl="http://localhost:$lightpid"
}

finish_http() {
    (test -e "$1/light.pid" && kill `cat "$1/light.pid"`) || true
}

check_remote_http() {
  if ! curl -fI "$1"; then
    echo Cannot reach "$1"
    exit 200
  fi
}