Changeset 1190 for obs_notify_generic
- Timestamp:
- Jun 17, 2015, 6:07:05 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
obs_notify_generic/obs_notify_generic.pm
r1188 r1190 48 48 }; 49 49 if ( not $self->{'logfile'} ) { 50 ##$self->{'logfile'} = "/tmp/notify_generic.log"; 50 51 $self->{'logfile'} = "/srv/obs/log/notify_generic.log"; 51 #$self->{'logfile'} = "/tmp/notify_generic.log";52 52 } 53 53 bless $self, shift; … … 60 60 61 61 $type = "UNKNOWN" unless $type; 62 62 63 63 my $cfg_type; 64 64 if ( $self->{'cfg'}->{$type} ) { … … 75 75 #print "key: $key\n"; 76 76 #print "value: $value\n"; 77 if ( not( exists($paramRef->{$key}) ) ) { 78 error_msg( "$type (". Data::Dumper->new( [$paramRef] )->Indent(0)->Dump ."): filter for '". $key ."' is invalid" ); 77 if ( not( exists( $paramRef->{$key} ) ) ) { 78 error_msg( "$type (" 79 . Data::Dumper->new( [$paramRef] )->Indent(0)->Dump 80 . "): filter for '" 81 . $key 82 . "' is invalid" ); 79 83 $match = 0; 84 80 85 # exit loop 81 86 last; … … 88 93 if ( $entry->{'action'} ) { 89 94 90 #print $entry->{'action'}, "\n";91 95 if ( $paramRef->{'project'} ) { 92 93 94 $paramRef->{'project_path'}="/srv/obs/repos/" . $project;96 my $project = $paramRef->{'project'}; 97 $project =~ s/:/:\//g; 98 $paramRef->{'project_path'} = "/srv/obs/repos/" . $project; 95 99 } 96 # create regex, 100 101 # create regex, 97 102 # test against longest string first to avoid partial replacement ($repo, $repository) 98 my $check = join '|', sort { 99 length($b) <=> length($a) 100 } keys %{$paramRef}; 103 my $check = join '|', 104 sort { length($b) <=> length($a) } keys %{$paramRef}; 101 105 my $action = $entry->{'action'}; 102 106 $action =~ s/\$($check)/$paramRef->{$1}/g; 103 107 104 105 106 107 108 108 $extra = { 109 'action_template' => $entry->{'action'}, 110 'action' => $action, 111 }; 112 109 113 #$self->run_wait( $action, $extra ); 110 114 $self->run_daemon( $action, $extra ); … … 124 128 my ( $self, $action, $extra ) = @_; 125 129 126 #print $action, "\n"; 127 my $in = undef; 128 my $out; 129 my $err; 130 my $rc; 131 eval { 132 my $process = 133 IPC::Run::start( [ "sh", "--login", "-c", "HOME=/usr/lib/obs $action", "2>&1" ], 134 \$in, \$out, \$err ); 135 $process->finish(); 136 $rc = $process->result(0); 137 }; 138 if ($@) { 139 140 #print "eval: ", $@; 141 $out = join( "\n", $@ ); 142 $rc = 127; 143 } 144 145 #print "rc: ", $rc, "\n"; 146 #print "out: ", $out, "\n"; 147 chomp($out); 148 149 #print "err: ", $err, "\n"; 150 $extra->{'returncode'} = $rc; 151 $extra->{'output'} = $out; 130 my $in = undef; 131 my $out; 132 my $err; 133 my $rc; 134 eval { 135 my $process = 136 IPC::Run::start( 137 [ "sh", "--login", "-c", "HOME=/usr/lib/obs $action", "2>&1" ], 138 \$in, \$out, \$err ); 139 $process->finish(); 140 $rc = $process->result(0); 141 }; 142 if ($@) { 143 144 #print "eval: ", $@; 145 $out = join( "\n", $@ ); 146 $rc = 127; 147 } 148 149 chomp($out); 150 151 $extra->{'returncode'} = $rc; 152 $extra->{'output'} = $out; 152 153 } 153 154 … … 156 157 my ( $self, $action, $extra ) = @_; 157 158 158 my $daemon=Proc::Daemon->new(); 159 my $pid=$daemon->Init( { 160 exec_command => "date --rfc-3339=seconds; echo '$action'; $action", 161 child_STDOUT => "+>>" . $self->{'logfile'} . ".out.log", 159 my $daemon = Proc::Daemon->new(); 160 my $pid = $daemon->Init( 161 { 162 exec_command => "date --rfc-3339=seconds; echo '$action'; $action", 163 child_STDOUT => "+>>" . $self->{'logfile'} . ".out.log", 162 164 child_STDERR => "+>>" . $self->{'logfile'} . ".out.log", 163 } ); 164 165 #print $daemon->Status($pid); 166 165 } 166 ); 167 168 #print $daemon->Status($pid); 169 167 170 $extra->{'pid'} = $pid; 168 171 } … … 193 196 194 197 print $fh localtime->strftime("%Y%m%d %H%M%S"), " TYPE=$type"; 195 198 196 199 if ($extra) { 197 200 print $fh "\n";
Note:
See TracChangeset
for help on using the changeset viewer.