perkeep/dev-server

74 lines
1.9 KiB
Plaintext
Raw Normal View History

#!/usr/bin/perl
use strict;
use FindBin qw($Bin);
use Getopt::Long;
sub usage {
die "Usage: dev-server [--wipe] <portnumber> -- [other_blobserver_opts]";
}
my $opt_wipe;
my $opt_all; # listen on all interfaces
GetOptions("wipe" => \$opt_wipe,
"all" => \$opt_all,
)
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 camlistored";
system("./build.pl", "clients/go/camdbinit") and die "Failed to build camdbinit";
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";
}
2011-05-21 16:26:20 +00:00
my ($bsroot, $s1root, $s2root) = ("$root/bs", "$root/s1", "$root/s2");
for my $d ($bsroot, $s1root, $s2root) {
unless (-d $d) {
system("mkdir", "-p", $d) and die "Failed to create $d.\n";
}
}
my $DBNAME = "devcamlistore";
my @opts;
if ($opt_wipe) {
push @opts, "-wipe";
} else {
push @opts, "-ignoreexists";
}
system("./clients/go/camdbinit/camdbinit",
"-user=root",
"-password=root",
"-host=localhost",
"-database=$DBNAME",
@opts) and die "Failed to run camdbinit.\n";
my $base = "http://localhost:$port";
my $listen = "127.0.0.1:$port";
if ($opt_all) {
$listen = "0.0.0.0:$port";
my $host = `hostname`;
chomp $host;
$base = "http://$host:$port";
}
print "Starting dev server on $base/ui/ with password \"pass$port\"\n";
$ENV{CAMLI_BASEURL} = $base;
$ENV{CAMLI_PASSWORD} = "pass$port";
2011-05-21 16:26:20 +00:00
$ENV{CAMLI_ROOT} = $bsroot;
$ENV{CAMLI_ROOT_SHARD1} = $s1root;
$ENV{CAMLI_ROOT_SHARD2} = $s2root;
$ENV{CAMLI_PORT} = $port;
$ENV{CAMLI_SECRET_RING} = "$Bin/lib/go/camli/jsonsign/testdata/test-secring.gpg";
exec("$FindBin::Bin/server/go/camlistored/camlistored",
"-configfile=$Bin/config/dev-server-config.json",
"-listen=$listen",
@ARGV);