line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MediaCloud::JobManager::Worker; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
272
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
8
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
18
|
|
9
|
1
|
|
|
1
|
|
3
|
use Modern::Perl "2012"; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
72
|
use MediaCloud::JobManager; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
12
|
|
12
|
1
|
|
|
1
|
|
4
|
use MediaCloud::JobManager::Configuration; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
3
|
use Log::Log4perl qw(:easy); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
15
|
|
|
|
|
|
|
Log::Log4perl->easy_init( { level => $DEBUG, utf8 => 1, layout => "%d{ISO8601} [%P]: %m%n" } ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub import_function($) |
19
|
|
|
|
|
|
|
{ |
20
|
0
|
|
|
0
|
0
|
|
my ( $path_or_name ) = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
eval { |
23
|
0
|
0
|
|
|
|
|
if ( $path_or_name =~ /\.pm$/ ) |
24
|
|
|
|
|
|
|
{ |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$path_or_name = require $path_or_name; |
30
|
0
|
0
|
|
|
|
|
if ( $path_or_name . '' eq '1' ) |
31
|
|
|
|
|
|
|
{ |
32
|
0
|
|
|
|
|
|
LOGDIE( "The function package should return __PACKAGE__ at the end of the file instead of just 1." ); |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
$path_or_name->import(); |
35
|
0
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else |
38
|
|
|
|
|
|
|
{ |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
( my $file = $path_or_name ) =~ s|::|/|g; |
41
|
0
|
|
|
|
|
|
require $file . '.pm'; |
42
|
0
|
|
|
|
|
|
$path_or_name->import(); |
43
|
0
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} or do |
46
|
0
|
0
|
|
|
|
|
{ |
47
|
0
|
|
|
|
|
|
LOGDIE( "Unable to find function in '$path_or_name': $@" ); |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $path_or_name; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub start_worker($) |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
0
|
0
|
|
my ( $function_name_or_path ) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $function_name = import_function( $function_name_or_path ); |
59
|
0
|
|
|
|
|
|
my $config = $function_name->configuration(); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
INFO( "Starting function '$function_name' from '$function_name_or_path'." ); |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$config->{ broker }->start_worker( $function_name ); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
INFO( "Done." ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|