2011-03-03 05:39:58 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
2011-05-01 23:10:53 +00:00
|
|
|
use FindBin qw($Bin);
|
2011-03-03 05:39:58 +00:00
|
|
|
use Getopt::Long;
|
|
|
|
|
|
|
|
sub usage {
|
2011-05-09 18:49:02 +00:00
|
|
|
die "Usage: dev-blobserver [--wipe] [--tls] <portnumber> -- [other_blobserver_opts]";
|
2011-03-03 05:39:58 +00:00
|
|
|
}
|
|
|
|
|
2012-03-06 00:36:28 +00:00
|
|
|
chdir $Bin or die;
|
|
|
|
|
2011-03-03 05:39:58 +00:00
|
|
|
my $opt_wipe;
|
2011-05-09 18:49:02 +00:00
|
|
|
my $opt_tls;
|
|
|
|
GetOptions(
|
|
|
|
"wipe" => \$opt_wipe,
|
|
|
|
"tls" => \$opt_tls,
|
|
|
|
) or usage();
|
2011-03-03 05:39:58 +00:00
|
|
|
|
2011-05-09 19:22:31 +00:00
|
|
|
my $port = shift;
|
|
|
|
$port = "3179" unless defined($port);
|
2011-03-03 05:39:58 +00:00
|
|
|
usage() unless $port =~ /^\d+$/;
|
|
|
|
|
2012-03-06 00:36:28 +00:00
|
|
|
unless ($ENV{GOPATH}) {
|
|
|
|
$ENV{GOPATH} = "$Bin/gopath"
|
|
|
|
}
|
|
|
|
|
|
|
|
system("go", "install", "./server/camlistored") and die "Failed to build camlistored";
|
2011-03-03 05:39:58 +00:00
|
|
|
|
2012-03-06 00:36:28 +00:00
|
|
|
my $root = "/tmp/camliroot-$ENV{USER}/port$port/";
|
2011-03-03 05:39:58 +00:00
|
|
|
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";
|
2011-05-01 23:10:53 +00:00
|
|
|
$ENV{CAMLI_PORT} = $port;
|
|
|
|
$ENV{CAMLI_ROOT} = $root;
|
2011-05-09 18:49:02 +00:00
|
|
|
$ENV{CAMLI_TLS_CRT_FILE} = $opt_tls ? "$Bin/config/dev-tls.crt" : "";
|
|
|
|
$ENV{CAMLI_TLS_KEY_FILE} = $opt_tls ? "$Bin/config/dev-tls.key" : "";
|
2012-03-06 00:36:28 +00:00
|
|
|
exec("$ENV{GOPATH}/bin/camlistored",
|
2011-05-01 23:10:53 +00:00
|
|
|
"-configfile=$Bin/config/dev-blobserver-config.json",
|
2011-05-09 19:22:31 +00:00
|
|
|
"-listen=127.0.0.1:$port",
|
2011-03-03 05:39:58 +00:00
|
|
|
@ARGV);
|
2011-05-09 18:49:02 +00:00
|
|
|
|
2012-03-06 00:36:28 +00:00
|
|
|
die "exec failure: $!\n";
|