-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsourcerabbit.pl
More file actions
executable file
·33 lines (31 loc) · 923 Bytes
/
sourcerabbit.pl
File metadata and controls
executable file
·33 lines (31 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/perl -w
use strict;
# usage: ./sourcerabbit.pl
# fetches rabbitmq events and stores entries in queue dir
use JSON::XS;
use lib ".";
use config;
use common;
use source::rabbitmq;
use source::OBS;
use source::gitea;
sub diag(@) {print @_,"\n"}
#{}
$|=1;
$SIG{ALRM} = sub {source::rabbitmq::close(); exit 0};
source::rabbitmq::init();
while(my $data=source::rabbitmq::fetchone()) {
alarm(24*3600);
my $srmentions;
if(exists($data->{body}) || $data->{routing_key} =~ /\.src\..*pull_request/) {
if(exists $data->{pull_request}) { $data = $data->{pull_request} }
if(exists $data->{json}) { $data = $data->{json} }
$srmentions=source::gitea::getprmentions($data);
} else {
$srmentions=source::OBS::getsrmentions($data);
}
foreach my $m (@$srmentions) {
diag("adding $data->{number} ".JSON::XS->new->canonical->encode($m));
common::enqueue($m);
}
}