Add minion support.

master
Kaitlyn Parkhurst 3 years ago
parent 4f4a4ae8d1
commit 19f2a43791
  1. 1
      Web/cpanfile
  2. 12
      Web/lib/MJB/Web.pm
  3. 17
      Web/lib/MJB/Web/Tasks/CreateBlog.pm
  4. 18
      Web/lib/MJB/Web/Tasks/DeployBlog.pm
  5. 15
      Web/lib/MJB/Web/Tasks/PurgeBlog.pm

@ -1,3 +1,4 @@
requires 'Minion';
requires 'Mojolicious';
requires 'Mojo::Pg';
requires 'Mojo::File';

@ -21,6 +21,13 @@ sub startup ($self) {
return state $db = MJB::DB->connect($config->{database}->{mjb});
});
# Minion Plugin & Tasks
$self->plugin( Minion => { Pg => $self->config->{database}->{minion} } );
$self->minion->add_task( create_blog => 'MJB::Web::Task::CreateBlog' );
$self->minion->add_task( purge_blog => 'MJB::Web::Task::PurgeBlog' );
$self->minion->add_task( deploy_blog => 'MJB::Web::Task::DeployBlog' );
# Standard router.
my $r = $self->routes->under( '/' => sub ($c) {
@ -61,6 +68,11 @@ sub startup ($self) {
return undef;
});
# Minion Admin Panel
$self->plugin( 'Minion::Admin' => {
route => $admin->under('/minion' => sub ($c) { return 1; } ),
});
# General Informational Pages
$r->get ( '/' )->to( 'Root#index' )->name('show_homepage' );
$r->get ( '/about' )->to( 'Root#about' )->name('show_about' );

@ -0,0 +1,17 @@
package MJB::Web::Tasks::CreateBlog;
use Mojo::Base 'Minion::Job', -signatures;
use Mojo::File qw( curfile );
use File::Copy::Recursive qw( dircopy );
use IPC::Run3;
sub run ( $job, $blog_id ) {
my $blog = $job->app->db->blog( $blog_id );
# Create clone of standard jekyll blog in repos/user_id/blog_id
# Set the git configuration for the clone so that it goes to gitea.
# TODO: add gitea user with ssh key?
}
1;

@ -0,0 +1,18 @@
package MJB::Web::Tasks::DeployBlog;
use Mojo::Base 'Minion::Job', -signatures;
use Mojo::File qw( curfile );
use File::Copy::Recursive qw( dircopy );
use IPC::Run3;
sub run ( $job, $blog_id ) {
my $blog = $job->app->db->blog( $blog_id );
# Check out the blog repo to a build area.
# Build the blog with the jekyll builder in podman
# Use ansible to deploy the blog to the web servers.
}
1;

@ -0,0 +1,15 @@
package MJB::Web::Tasks::CreateBlog;
use Mojo::Base 'Minion::Job', -signatures;
use Mojo::File qw( curfile );
use File::Copy::Recursive qw( dircopy );
use IPC::Run3;
sub run ( $job, $blog_id ) {
my $blog = $job->app->db->blog( $blog_id );
# Remove the blog from gitea storage
# Delete the blog from the web servers
}
1;
Loading…
Cancel
Save