forked from perkeep/perkeep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-blobserver
More file actions
executable file
·51 lines (40 loc) · 1.24 KB
/
dev-blobserver
File metadata and controls
executable file
·51 lines (40 loc) · 1.24 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl
use strict;
use FindBin qw($Bin);
use Getopt::Long;
sub usage {
die "Usage: dev-blobserver [--wipe] [--tls] <portnumber> -- [other_blobserver_opts]";
}
chdir $Bin or die;
my $opt_wipe;
my $opt_tls;
GetOptions(
"wipe" => \$opt_wipe,
"tls" => \$opt_tls,
) or usage();
my $port = shift;
$port = "3179" unless defined($port);
usage() unless $port =~ /^\d+$/;
unless ($ENV{GOPATH}) {
$ENV{GOPATH} = "$Bin/gopath"
}
system("go", "install", "./server/camlistored") and die "Failed to build camlistored";
my $root = "/tmp/camliroot-$ENV{USER}/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";
$ENV{CAMLI_PORT} = $port;
$ENV{CAMLI_ROOT} = $root;
$ENV{CAMLI_TLS_CRT_FILE} = $opt_tls ? "$Bin/config/dev-tls.crt" : "";
$ENV{CAMLI_TLS_KEY_FILE} = $opt_tls ? "$Bin/config/dev-tls.key" : "";
exec("$ENV{GOPATH}/bin/camlistored",
"-configfile=$Bin/config/dev-blobserver-config.json",
"-listen=127.0.0.1:$port",
@ARGV);
die "exec failure: $!\n";