9 analysis-jobqueue-rm.pl -- Remove one job from the redis jobqueue on analysis
13 $0 jobnumber [jobnumber...]
21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
29 Don't do anything, just tell what you would do
35 Remove a job by number. Does just this if argument is 639408:
37 2015-08-03 21:31 redis-cli get analysis:jobqueue:jobs:639408:hex
38 2015-08-03 21:31 redis-cli get analysis:jobqueue:jobs:639408:descr
39 2015-08-03 21:32 redis-cli del analysis:jobqueue:jobs:40aebf9db9a664e052e4b886d0c724bbce3cf4d4:id
40 2015-08-03 21:32 redis-cli del analysis:jobqueue:jobs:639408:hex
41 2015-08-03 21:32 redis-cli del analysis:jobqueue:jobs:639408:descr
42 2015-08-03 21:33 redis-cli srem analysis:jobqueue:runningjobs 639408
48 use lib
"$FindBin::Bin/../lib";
54 use File
::Basename
qw(dirname);
55 use File
::Path
qw(mkpath);
60 use Hash
::Util
qw(lock_keys);
63 lock_keys
%Opt, map { /([^=|!]+)/ } @opt;
72 use Time
::HiRes
qw(sleep);
73 my $redis = Redis
->new(reconnect
=> 120, every
=> 1000);
74 @ARGV or pod2usage
(1);
75 for my $job_id (@ARGV) {
76 if (my $hex = $redis->get("analysis:jobqueue:jobs:$job_id:hex")) {
77 my $descr = $redis->get("analysis:jobqueue:jobs:$job_id:descr");
78 warn "found job_id $job_id, hex $hex, descr $descr\n";
79 next if $Opt{"dry-run"};
80 for my $del_frag ("$hex\:id", "$job_id\:hex", "$job_id\:descr") {
81 my $del = "analysis:jobqueue:jobs:$del_frag";
82 my $ret = $redis->del($del);
83 warn "del $del => ret $ret\n";
84 die "Could not delete $del, giving up" unless $ret;
86 my $srem = "analysis:jobqueue:runningjobs";
87 my $ret = $redis->srem($srem, $job_id);
88 warn "srem $srem $job_id => ret $ret\n";
89 die "Could not srem $srem $job_id, giving up" unless $ret;
91 die "Failing: Job_id $job_id unknown";
97 # cperl-indent-level: 4