1 |
commit: 8a60a36dfca344e002faad387f58b01b09cafa22 |
2 |
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Apr 30 20:29:38 2020 +0000 |
4 |
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Apr 30 20:29:38 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gentoo-mirrorstats.git/commit/?id=8a60a36d |
7 |
|
8 |
probe-mirmon: make even less stderr |
9 |
|
10 |
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> |
11 |
|
12 |
probe-mirmon | 11 +++++++++-- |
13 |
1 file changed, 9 insertions(+), 2 deletions(-) |
14 |
|
15 |
diff --git a/probe-mirmon b/probe-mirmon |
16 |
index 6d67fbf..1e10ef1 100755 |
17 |
--- a/probe-mirmon |
18 |
+++ b/probe-mirmon |
19 |
@@ -22,6 +22,7 @@ use warnings; |
20 |
use Date::Parse (); # dev-perl/TimeDate |
21 |
use File::Tempdir; # dev-perl/File-Tempdir |
22 |
use WWW::Curl::Easy; |
23 |
+use Capture::Tiny qw/capture/; |
24 |
|
25 |
sub main { |
26 |
my ( $timeout, $url ) = @_; |
27 |
@@ -84,9 +85,15 @@ sub handle_rsync { |
28 |
|
29 |
$file =~ s/\W/_/g; # translate all non-letters to _ |
30 |
|
31 |
- if ( my $fail = system '/usr/bin/rsync', qw( -q --no-motd --timeout ), $timeout, $url, "$dir/$file", '2>/dev/null' ) { |
32 |
+ # https://stackoverflow.com/a/6331618/1583179 |
33 |
+ my $ret; |
34 |
+ my ($stdout, $stderr) = capture { |
35 |
+ $ret = system '/usr/bin/rsync', qw( -q --no-motd --timeout ), $timeout, $url, "$dir/$file"; |
36 |
+ }; |
37 |
+ if ($ret!=0) { |
38 |
#warn "rsync failed, exit code $fail, $! $? $@\n"; |
39 |
- exit $fail; |
40 |
+ #exit $ret; |
41 |
+ exit 800; |
42 |
} |
43 |
|
44 |
open my $fh, '<', "$dir/$file" or do { |