Skip to content

Commit

Permalink
- Added a check to the Rock Update block to ensure the block compile …
Browse files Browse the repository at this point in the history
…and less compile are not running when the update button is pushed.
  • Loading branch information
ethan-sparkdevnetwork committed Jan 21, 2022
1 parent 913f497 commit 8390c2d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
15 changes: 11 additions & 4 deletions RockWeb/App_Code/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public class Global : System.Web.HttpApplication
// cache callback object
private static CacheItemRemovedCallback _onCacheRemove = null;

public static Thread CompileThemesThread = null;
public static Thread BlockTypeCompilationThread = null;

#endregion

#region Asp.Net Events
Expand Down Expand Up @@ -227,7 +230,7 @@ protected void Application_Start( object sender, EventArgs e )
private static void StartCompileThemesThread()
{
// compile less files
new Thread( () =>
CompileThemesThread = new Thread( () =>
{
/* Set to background thread so that this thread doesn't prevent Rock from shutting down. */
var stopwatchCompileLess = Stopwatch.StartNew();
Expand All @@ -248,7 +251,9 @@ private static void StartCompileThemesThread()
System.Diagnostics.Debug.WriteLine( "RockTheme.CompileAll messages: " + messages );
}
}
} ).Start();
} );

CompileThemesThread.Start();
}

/// <summary>
Expand All @@ -272,7 +277,7 @@ private static void StartWorkflowActionUpdateAttributesThread()
/// </summary>
private static void StartBlockTypeCompilationThread()
{
new Thread( () =>
BlockTypeCompilationThread = new Thread( () =>
{
// Set to background thread so that this thread doesn't prevent Rock from shutting down.
Thread.CurrentThread.IsBackground = true;
Expand All @@ -292,7 +297,9 @@ private static void StartBlockTypeCompilationThread()
BlockTypeService.VerifyBlockTypeInstanceProperties( allUsedBlockTypeIds, _threadCancellationTokenSource.Token );

Debug.WriteLine( string.Format( "[{0,5:#} seconds] All block types Compiled", stopwatchCompileBlockTypes.Elapsed.TotalSeconds ) );
} ).Start();
} );

BlockTypeCompilationThread.Start();
}

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions RockWeb/Blocks/Core/RockUpdate.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
You will need to upgrade your database in order to proceed with that update.
</p>
</Rock:NotificationBox>
<Rock:NotificationBox ID="nbCompileThreadsIssue" runat="server" NotificationBoxType="Warning" Visible="false">
<h2><i class="fa fa-exclamation-triangle"></i> Background Process Running</h2>
<p>
Rock is running one or more processes that may lock files that will be updated. These will be checked again after clicking the update button. If this message appears again wait a minute and try again.
</p>
</Rock:NotificationBox>
<asp:Panel ID="pnlNoUpdates" runat="server">
<div class="well well-message">
<h1>Everything Is Shipshape</h1>
Expand Down
19 changes: 19 additions & 0 deletions RockWeb/Blocks/Core/RockUpdate.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ protected override void OnLoad( EventArgs e )
nbRepoWarning.Visible = true;
}

if ( Global.CompileThemesThread.IsAlive || Global.BlockTypeCompilationThread.IsAlive )
{
// Display a warning here but don't prevent them from going forward. This will be checked again after clicking update.
nbCompileThreadsIssue.Visible = true;
}
else
{
// Hide the warning
nbCompileThreadsIssue.Visible = false;
}

DisplayRockVersion();
if ( !IsPostBack )
{
Expand Down Expand Up @@ -472,6 +483,14 @@ private void SendStatictics( string version )

protected void mdConfirmInstall_SaveClick( object sender, EventArgs e )
{
if ( Global.CompileThemesThread.IsAlive || Global.BlockTypeCompilationThread.IsAlive )
{
// Show message here and return
nbCompileThreadsIssue.Visible = true;
return;
}

nbCompileThreadsIssue.Visible = false;
mdConfirmInstall.Hide();
Update( hdnInstallVersion.Value );
}
Expand Down

0 comments on commit 8390c2d

Please sign in to comment.