equal
deleted
inserted
replaced
11 # GNU General Public License for more details. |
11 # GNU General Public License for more details. |
12 # |
12 # |
13 # You should have received a copy of the GNU General Public License |
13 # You should have received a copy of the GNU General Public License |
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 |
15 |
16 use Gearman::Worker; |
16 use Mojo::Base -strict; |
|
17 use lib 'lib'; |
|
18 |
17 use Mojo::JSON; |
19 use Mojo::JSON; |
18 use Mojo::Util qw(decode slurp); |
20 use Mojo::Util qw(decode slurp); |
19 use Mojo::Loader; |
21 use Mojo::Loader; |
20 use File::Temp; |
22 use File::Temp; |
21 use lib 'lib'; |
23 use Gearman::Worker; |
|
24 use Mojolicious; |
|
25 use Mojo::Home; |
22 |
26 |
23 sub load_config { |
27 sub load_config { |
24 my ($file) = @_; |
28 my $app = Mojolicious->new; |
25 my $code = decode('UTF-8', slurp $file); |
29 $app->home(Mojo::Home->new("$FindBin::Bin/../")); |
26 return eval($code); |
30 $app->moniker("CrashTest"); |
|
31 return $app->plugin('Config'); |
27 } |
32 } |
28 |
33 |
29 my $config = load_config($ARGV[0]); |
34 my $config = load_config(); |
30 |
35 |
31 my $loader = Mojo::Loader->new; |
36 my $loader = Mojo::Loader->new; |
32 |
37 |
33 my $storage_class = $config->{Storage}->{Type}; |
38 my $storage_class = $config->{Storage}->{Type}; |
34 if (my $e = $loader->load($storage_class)) { |
39 if (my $e = $loader->load($storage_class)) { |
36 } |
41 } |
37 |
42 |
38 my $storage = $storage_class->new(config => $config->{Storage}); |
43 my $storage = $storage_class->new(config => $config->{Storage}); |
39 |
44 |
40 my $worker = Gearman::Worker->new(job_servers => $config->{DecodeQueue}->{GearmanServers}); |
45 my $worker = Gearman::Worker->new(job_servers => $config->{DecodeQueue}->{GearmanServers}); |
41 |
|
42 |
46 |
43 $worker->register_function("dump_decode", 60, sub { |
47 $worker->register_function("dump_decode", 60, sub { |
44 my $args = $_[0]->arg; |
48 my $args = $_[0]->arg; |
45 |
49 |
46 my $json = Mojo::JSON->new(); |
50 my $json = Mojo::JSON->new(); |