store data in json timestamped files
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 16 Jul 2011 10:00:53 +0000 (10:00 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 16 Jul 2011 10:00:53 +0000 (10:00 +0000)
rsync-piper.pl
test.sh

index 59ad0ae..07fedfb 100755 (executable)
@@ -9,6 +9,7 @@ use IO::Select;
 use Time::HiRes;
 use Data::Dump qw(dump);
 use English;
+use JSON::XS;
 
 my $dir = '/srv/cloudstore/var';
 my $log_fifo = "$dir/rsyncd.log";
@@ -110,6 +111,13 @@ while(1) {
                        my @v = split(/\|/,$1);
                        @data{@k} = @v ; # FIXME validate?
                        print "transfer-log:",dump(\%data),$/;
+
+                       my $path = sprintf "users/%s/data/%.5f-%d",
+                               $data{user}, Time::HiRes::time(), $data{pid};
+                       open(my $json, '>', $path);
+                       print $json encode_json \%data;
+                       close $json;
+                       print $path, " ", -s $path, " bytes\n";
                }
        }
        close($log);
diff --git a/test.sh b/test.sh
index fae36f0..6d9449e 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -31,4 +31,8 @@ rm foo bar
 push dir-test --recursive --delete -v
 rm -Rf dir-test
 push . --recursive --delete -v
-pull non-existing
+
+ls -al /srv/cloudstore/users/dpavlin/data/
+
+pull non-existing # dies, must be last
+