store send_file and delete operation in log
authorDobrica Pavlinusic <dpavlin@rsync1>
Tue, 29 Nov 2011 23:02:34 +0000 (00:02 +0100)
committerDobrica Pavlinusic <dpavlin@rsync1>
Tue, 29 Nov 2011 23:02:34 +0000 (00:02 +0100)
gearman/send_file.pl

index 7652e39..6ef1c87 100755 (executable)
@@ -15,6 +15,9 @@ use Gearman::Worker;
 my $worker = Gearman::Worker->new;
 $worker->job_servers('127.0.0.1:4730');
 
+open(my $log, '>>', '/rsync1/s1/log/send_file.log');
+select($log); $|++;
+
 $worker->register_function( send_file => sub {
        my ($job) = @_;
 
@@ -34,6 +37,8 @@ $worker->register_function( send_file => sub {
        make_path $t_basedir unless -d $t_basedir;
        link $f_dir . $from => $t_dir . $to;
 
+       print "send#$work#", -s $t_dir.$to, "#$!\n";
+
        die "ERROR: $!" if $!;
 
        return "send_file $f_dir $from -> $t_dir $to";
@@ -51,10 +56,13 @@ $worker->register_function( delete => sub {
        my $full = $dir . $work;
 
        if ( -d $full ) {
+               print "delete_tree#$work\n";
                warn "remove_tree $full\n";
                remove_tree $full;
        } else {
+               print "delete_file#$work#", -s $full, "\n";
                warn "unlink $full\n";
+               unlink $full;
        }
        if ( $! ) {
                warn "ERROR: $!";