diff options
author | Byron Jones <bjones@mozilla.com> | 2013-03-25 05:50:05 +0100 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2013-03-25 05:50:05 +0100 |
commit | 9c177145ceb127429b4dc71499ab879caf607fd4 (patch) | |
tree | b12ee791570ea109f053e942195b05154ade5d14 /arecibo.pl | |
parent | ddf489ad8abf9e0afa3d4545e784eab7c854bcbe (diff) | |
download | bugzilla-9c177145ceb127429b4dc71499ab879caf607fd4.tar.gz bugzilla-9c177145ceb127429b4dc71499ab879caf607fd4.tar.xz |
Bug 849120: change "send error to error reporter" from forking to running a process
Diffstat (limited to 'arecibo.pl')
-rw-r--r-- | arecibo.pl | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/arecibo.pl b/arecibo.pl new file mode 100644 index 000000000..a6199a194 --- /dev/null +++ b/arecibo.pl @@ -0,0 +1,55 @@ +#!/usr/bin/perl -w + +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +# +# report errors to arecibo +# expects a filename with a Data::Dumper serialised parameters +# called by Bugzilla::Arecibo +# + +use strict; +use warnings; + +use FindBin qw($Bin); +use lib $Bin; +use lib "$Bin/lib"; + +use Bugzilla; +use File::Slurp; +use POSIX qw(setsid nice); +use Safe; + +nice(19); + +# detach +open(STDIN, '</dev/null'); +open(STDOUT, '>/dev/null'); +open(STDERR, '>/dev/null'); +setsid(); + +# grab arecibo server url +my $arecibo_server = Bugzilla->params->{arecibo_server} || ''; +exit(1) unless $arecibo_server; + +# read data dump +exit(1) unless my $filename = shift; +my $dump = read_file($filename); +unlink($filename); + +# deserialise +my $cpt = new Safe; +$cpt->reval($dump) || exit(1); +my $data = ${$cpt->varglob('VAR1')}; + +# and post to arecibo +my $agent = LWP::UserAgent->new( + agent => 'bugzilla.mozilla.org', + timeout => 10, # seconds +); +$agent->post($arecibo_server, $data); |