mirror of https://github.com/perkeep/perkeep.git
Add dev-blobserver wrapper; remove run.sh
This commit is contained in:
parent
7381cbf4d1
commit
38a85571ca
|
@ -132,7 +132,7 @@ func main() {
|
|||
}
|
||||
} else {
|
||||
go func() {
|
||||
destErr <- sc.EnumerateBlobs(destBlobs)
|
||||
destErr <- dc.EnumerateBlobs(destBlobs)
|
||||
}()
|
||||
|
||||
// Merge sort srcBlobs and destBlobs
|
||||
|
|
|
@ -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);
|
|
@ -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 $@
|
||||
|
|
|
@ -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 $@
|
||||
|
|
|
@ -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 $@
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 "$@"
|
Loading…
Reference in New Issue