Add dev-blobserver wrapper; remove run.sh

This commit is contained in:
Brad Fitzpatrick 2011-03-02 21:39:58 -08:00
parent 7381cbf4d1
commit 38a85571ca
9 changed files with 52 additions and 20 deletions

View File

@ -132,7 +132,7 @@ func main() {
}
} else {
go func() {
destErr <- sc.EnumerateBlobs(destBlobs)
destErr <- dc.EnumerateBlobs(destBlobs)
}()
// Merge sort srcBlobs and destBlobs

35
dev-blobserver Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/perl
use strict;
use FindBin;
use Getopt::Long;
sub usage {
die "Usage: dev-blobserver [--wipe] <portnumber> -- [other_camlistored_opts]";
}
my $opt_wipe;
GetOptions("wipe" => \$opt_wipe)
or usage();
my $port = shift || "3179";
usage() unless $port =~ /^\d+$/;
system("./build.pl", "server/go/blobserver") and die "Failed to build.\n";
my $root = "/tmp/camliroot/port$port/";
if ($opt_wipe && -d $root) {
print "Wiping $root\n";
system("rm", "-rf", $root) and die "Failed to wipe $root.\n";
}
unless (-d $root) {
system("mkdir", "-p", $root) and die "Failed to create $root.\n";
}
print "Starting blobserver on http://localhost:$port/ in $root\n";
$ENV{CAMLI_PASSWORD} = "pass$port";
exec("$FindBin::Bin/server/go/blobserver/camlistored",
"-root=$root",
"-listen=:$port",
@ARGV);

View File

@ -1,4 +1,4 @@
#!/bin/sh
./build.pl camget && \
clients/go/camget/camget --verbose --blobserver=localhost:3179 --password=foo $@
clients/go/camget/camget --verbose --blobserver=localhost:3179 --password=pass3179 $@

View File

@ -1,4 +1,4 @@
#!/bin/sh
./build.pl camput && \
clients/go/camput/camput --verbose --blobserver=localhost:3179 --password=foo $@
clients/go/camput/camput --verbose --blobserver=localhost:3179 --password=pass3179 $@

View File

@ -1,4 +1,4 @@
#!/bin/sh
./build.pl camsync && \
clients/go/camsync/camsync --verbose --src=http://localhost:3179 --srcpassword=foo $@
clients/go/camsync/camsync --verbose --src=http://localhost:3179 --srcpassword=pass3179 $@

View File

@ -1,7 +1,13 @@
The /camli/<blobref> endpoint returns a blob the server knows about.
A request with the GET verb will return 200 and the blob contents if present, 404 if not. A request with the HEAD verb will return 200 and the blob meta data (i.e., content-length), or 404 if the blob is not present.
A request with the GET verb will return 200 and the blob contents if
present, 404 if not. A request with the HEAD verb will return 200 and
the blob meta data (i.e., content-length), or 404 if the blob is not
present.
The response must include an explicit Content-Length, even with HTTP/1.1.
(The one piece of metadata a blobserver keeps on a blob is its length,
which is used in both enumerate-blobs bodies and responses to blob GETs.)
Get the blob:

View File

@ -31,6 +31,7 @@ import (
"json"
"log"
"regexp"
"strconv"
"strings"
"time"
)
@ -208,6 +209,8 @@ func handleGet(conn http.ResponseWriter, req *http.Request, fetcher blobref.Fetc
}
}
input = bufReader
conn.SetHeader("Content-Length", strconv.Itoa64(size))
}
conn.SetHeader("Content-Type", contentType)

View File

@ -23,7 +23,6 @@ import (
"http"
"io"
"os"
"strconv"
)
func (c *Client) newRequest(method, url string) *http.Request {
@ -68,9 +67,9 @@ func (c *Client) FetchVia(b *blobref.BlobRef, v []*blobref.BlobRef) (blobref.Rea
return nil, 0, err
}
var size int64
if s := resp.Header.Get("Content-Length"); s != "" {
size, _ = strconv.Atoi64(s)
size := resp.ContentLength
if size == -1 {
return nil, 0, os.NewError("blobserver didn't return a Content-Length for blob")
}
return nopSeeker{resp.Body}, size, nil

View File

@ -1,11 +0,0 @@
#!/bin/sh
Bin=$(dirname $( readlink -f $0))
ROOT=/tmp/camliroot
if [ ! -d $ROOT ]; then
mkdir $ROOT
fi
export CAMLI_PASSWORD=foo
$Bin/../../../build.pl server/go/blobserver && $Bin/camlistored -root=$ROOT -listen=:3179 "$@"