File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,19 +13,19 @@ services:
1313 volumes :
1414 - ./etc/schema.sql:/docker-entrypoint-initdb.d/000_schema.sql:ro
1515 - blogdb_database:/var/lib/postgresql/data
16- # minion-database:
17- # image: postgres:11
18- # container_name: meshmage -minion-db
19- # ports:
20- # - 127.0.0.1:5433 :5432
21- # environment:
22- # - POSTGRES_PASSWORD=minion
23- # - POSTGRES_USER=minion
24- # - POSTGRES_DB=minion
25- # volumes:
26- # - minion_database:/var/lib/postgresql/data
16+ minion-database :
17+ image : postgres:11
18+ container_name : blogdb -minion
19+ ports :
20+ - 127.0.0.1:5400 :5432
21+ environment :
22+ - POSTGRES_PASSWORD=minion
23+ - POSTGRES_USER=minion
24+ - POSTGRES_DB=minion
25+ volumes :
26+ - minion_database:/var/lib/postgresql/data
2727
2828
2929volumes :
3030 blogdb_database :
31- # minion_database:
31+ minion_database :
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ requires 'Mojolicious::Plugin::RenderFile';
44requires ' Mojo::Pg' ;
55requires ' DateTime::Format::Pg' ;
66requires ' BlogDB::DB' ;
7+ requires ' WebService::WsScreenshot' ;
78
89test_requires " Test::Postgresql58" ;
910test_requires " Test::More" ;
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ sub startup ($self) {
3232 $c -> stash-> {template } = sprintf ( " %s /%s " , $c -> config-> {template_dir }, $name );
3333 });
3434
35+ $self -> plugin( ' BlogDB::Web::Plugin::MinionTasks' );
36+
3537 # Get the router.
3638 my $router = $self -> routes;
3739
Original file line number Diff line number Diff line change @@ -74,6 +74,9 @@ sub post_new_blog ($c) {
7474 ),
7575 });
7676
77+ $c -> minion-> enqueue( download_screenshot => [ $blog -> url, $blog -> id ] );
78+
79+
7780 # $c->redirect_to( $c->url_for( 'do_blog_edit', id => $blog->id, title => 'new' ) );
7881}
7982
Original file line number Diff line number Diff line change 1+ package BlogDB::Web::Plugin::MinionTasks ;
2+ use Mojo::Base ' Mojolicious::Plugin' , -signatures;
3+ use WebService::WsScreenshot;
4+ use Minion;
5+
6+ sub register ( $self , $app , $config ) {
7+
8+ my $screenshot = WebService::WsScreenshot-> new(
9+ base_url => $app -> config-> {ws_screenshot }-> {base_url },
10+ );
11+
12+ $app -> plugin( Minion => { Pg => $app -> config-> {database }-> {minion } } );
13+ $app -> plugin( ' Minion::Admin' );
14+
15+ $app -> minion-> add_task(download_screenshot => sub ( $job , $blog_url , $blog_id ) {
16+ $screenshot -> store_screenshot(
17+ url => $blog_url ,
18+ out_file => $job -> app-> config-> {ws_screenshot }-> {datadir } . " $blog_id .jpg" ,
19+ );
20+ });
21+
22+ }
23+
24+ 1;
You can’t perform that action at this time.
0 commit comments