mirror of https://github.com/perkeep/perkeep.git
45 lines
1.1 KiB
Perl
Executable File
45 lines
1.1 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
use FindBin qw($Bin);
|
|
use Getopt::Long;
|
|
|
|
sub usage {
|
|
die "Usage: dev-blobserver [--wipe] [--tls] <portnumber> -- [other_blobserver_opts]";
|
|
}
|
|
|
|
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+$/;
|
|
|
|
system("./build.pl", "server/go/camlistored") 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";
|
|
$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("$FindBin::Bin/server/go/camlistored/camlistored",
|
|
"-configfile=$Bin/config/dev-blobserver-config.json",
|
|
"-listen=127.0.0.1:$port",
|
|
@ARGV);
|
|
|