bin/gearman_decode_worker.pl
changeset 19 300b902b5461
parent 18 60db1090095b
child 20 169c73eb8881
--- a/bin/gearman_decode_worker.pl	Sat Apr 06 22:50:55 2013 +0200
+++ b/bin/gearman_decode_worker.pl	Sun Apr 07 00:02:00 2013 +0200
@@ -17,6 +17,7 @@
 use Mojo::JSON;
 use Mojo::Util qw(decode slurp);
 use File::Temp;
+use lib 'lib';
 
 sub load_config {
     my ($file) = @_;
@@ -25,7 +26,12 @@
 }
 
 my $config = load_config($ARGV[0]);
-my $worker = Gearman::Worker->new(job_servers => $config->{GearmanServers});
+
+eval "require $config->{Storage}->{Type}";
+my $storage = $config->{Storage}->{Type}->new($config->{Storage});
+
+my $worker = Gearman::Worker->new(job_servers => $config->{DecodeQueue}->{GearmanServers});
+
 
 $worker->register_function("dump_decode", 60, sub {
     my $args = $_[0]->arg;
@@ -34,9 +40,10 @@
     my $jsonin = $json->decode($args);
 
     my $file = File::Temp->new();
+    binmode($file);
     print $file $jsonin->{file};
 
-    my $cmd = $config->{MinidumpStackwalkJSON} . " " . $file->filename . " " . $config->{SymbolsPath};
+    my $cmd = $config->{Dumper}->{JSONStackwalker} . " " . $file->filename . " " . $config->{Dumper}->{SymbolsPath};
     my $out = qx($cmd 2>/dev/null) or die $!;
 
     my $pjson = $json->decode($out);
@@ -44,6 +51,10 @@
     # Create json for the params
     $pjson->{client_info} = $jsonin->{params};
 
+    my $uuidstr = $jsonin->{uuid};
+    $storage->store_dump($uuidstr, $file);
+    $storage->store_processed_data($uuidstr, $pjson);
+
     return $json->encode($pjson);
 });