From b4e21d6f2037e77752044577d708bc51abfdac43 Mon Sep 17 00:00:00 2001 From: Manager Bot Date: Sun, 27 Nov 2022 01:15:25 +0000 Subject: [PATCH] New build test. --- Web/lib/MJB/Web/Controller/Blog.pm | 31 +++++++++++++++++++------- Web/lib/MJB/Web/Task/InitializeBlog.pm | 3 --- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Web/lib/MJB/Web/Controller/Blog.pm b/Web/lib/MJB/Web/Controller/Blog.pm index 00304ee..88178f0 100644 --- a/Web/lib/MJB/Web/Controller/Blog.pm +++ b/Web/lib/MJB/Web/Controller/Blog.pm @@ -142,12 +142,18 @@ sub do_domain ( $c ) { return $c->redirect_error( $calling_route ) if $c->stash->{errors}; - # If we don't have an SSL domain, that means we need to get a cert through an - # http challenge. + + # Now I need to configure the web servers to handle this domain. + # + # If there is an $ssl_domain, then the SSL cert is already handled, + # likely a wildcard. + # + # Otherwise, make one and then configure nginx afterwards. + my $ssl_job_id = 0; if ( ! $ssl_domain ) { # Do not run this job in test mode. if ( ! $c->is_testmode ) { - my $ssl_job_id = $c->minion->enqueue( 'create_ssl_cert', [ $blog->id ], { + $ssl_job_id = $c->minion->enqueue( 'create_ssl_cert', [ $blog->id ], { notes => { '_bid_' . $blog->id => 1 }, priority => $blog->build_priority, queue => 'certbot', @@ -155,6 +161,19 @@ sub do_domain ( $c ) { $blog->create_related( 'jobs', { minion_job_id => $ssl_job_id } ); } } + + # This code creates the nginx configuration and everything. Don't run it in + # test mode. + if ( ! $c->is_testmode ) { + my $build_job_id = $c->minion->enqueue( 'initialize_blog', [ $blog->id ], { + notes => { '_bid_' . $blog->id => 1 }, + priority => $blog->build_priority, + + # We we're creating an SSL cert, wait until that is done. + $ssl_job_id ? ( parents => [ $ssl_job_id ] ) : (), + }); + $blog->create_related( 'jobs', { minion_job_id => $build_job_id } ); + } $c->redirect_to( $c->url_for( 'show_blog_settings', { id => $blog->id } ) ); } @@ -202,11 +221,7 @@ sub do_settings ( $c ) { $jekyll->write_config; - my $build_job_id = $c->minion->enqueue( 'initialize_blog', [ $blog->id ], { - notes => { '_bid_' . $blog->id => 1 }, - priority => $blog->build_priority, - }); - $blog->create_related( 'jobs', { minion_job_id => $build_job_id } ); + $c->sync_blog( $blog ); $c->flash( confirmation => "Welcome to the dashboard for your new blog!" ); $c->redirect_to( $c->url_for( 'show_dashboard_blog', { id => $blog->id } ) ); diff --git a/Web/lib/MJB/Web/Task/InitializeBlog.pm b/Web/lib/MJB/Web/Task/InitializeBlog.pm index c4163d0..ed9bc34 100644 --- a/Web/lib/MJB/Web/Task/InitializeBlog.pm +++ b/Web/lib/MJB/Web/Task/InitializeBlog.pm @@ -48,9 +48,6 @@ sub run ( $job, $blog_id ) { $job->note( is_config_deployed => 1 ); - # Deploy the initial blog. - $job->app->sync_blog( $blog ); - $job->finish( ); }