mirror of https://github.com/perkeep/perkeep.git
script to init mysql and start indexer blobserver
This commit is contained in:
parent
e36a7679b2
commit
02fcf406fe
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use FindBin;
|
||||
use Getopt::Long;
|
||||
use DBI;
|
||||
|
||||
sub usage {
|
||||
die "Usage: dev-indexer [--wipe] <portnumber> -- [other_camlistored_opts]";
|
||||
}
|
||||
|
||||
my $opt_wipe;
|
||||
GetOptions("wipe" => \$opt_wipe)
|
||||
or usage();
|
||||
|
||||
my $port = shift || "3200";
|
||||
usage() unless $port =~ /^\d+$/;
|
||||
|
||||
system("./build.pl", "server/go/blobserver") and die "Failed to build.\n";
|
||||
|
||||
# NOTE: Root required but not used by indexer blobserver
|
||||
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";
|
||||
}
|
||||
|
||||
if ($opt_wipe) {
|
||||
system("mysqladmin", "-uroot", "-proot", "drop", "camlistore");
|
||||
system("mysqladmin", "-uroot", "-proot", "create", "camlistore") and die "Could not create MySQL database on localhost.\n";
|
||||
my $dbh = DBI->connect("DBI:mysql:database=camlistore", "root", "root", {
|
||||
"RaiseError" => 1,
|
||||
}) or die "Failed to connect to MySQL on localhost.\n";
|
||||
|
||||
# Begin schema creation.
|
||||
$dbh->do("CREATE TABLE blobs (".
|
||||
"blobref VARCHAR(100) NOT NULL PRIMARY KEY, ".
|
||||
"size INTEGER NOT NULL, ".
|
||||
"type VARCHAR(100)".
|
||||
")");
|
||||
}
|
||||
|
||||
print "Starting blobserver with indexer on http://localhost:$port/ in $root\n";
|
||||
|
||||
$ENV{CAMLI_PASSWORD} = "pass$port";
|
||||
exec("$FindBin::Bin/server/go/blobserver/camlistored",
|
||||
"-root=$root", # NOTE: Root required but not used by indexer blobserver
|
||||
"-listen=:$port",
|
||||
"-devmysqlindexer",
|
||||
@ARGV);
|
Loading…
Reference in New Issue