mirror of https://github.com/Squidex/squidex.git
8 changed files with 184 additions and 37 deletions
@ -0,0 +1,31 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Migrate_01; |
||||
|
using Squidex.Infrastructure.Log; |
||||
|
|
||||
|
namespace Squidex.Config.Startup |
||||
|
{ |
||||
|
public sealed class RebuilderHost : SafeHostedService |
||||
|
{ |
||||
|
private readonly RebuildRunner rebuildRunner; |
||||
|
|
||||
|
public RebuilderHost(IApplicationLifetime lifetime, ISemanticLog log, RebuildRunner rebuildRunner) |
||||
|
: base(lifetime, log) |
||||
|
{ |
||||
|
this.rebuildRunner = rebuildRunner; |
||||
|
} |
||||
|
|
||||
|
protected override Task StartAsync(ISemanticLog log, CancellationToken ct) |
||||
|
{ |
||||
|
return rebuildRunner.RunAsync(ct); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
namespace Migrate_01 |
||||
|
{ |
||||
|
public sealed class RebuildOptions |
||||
|
{ |
||||
|
public bool Apps { get; set; } |
||||
|
|
||||
|
public bool Assets { get; set; } |
||||
|
|
||||
|
public bool Contents { get; set; } |
||||
|
|
||||
|
public bool Rules { get; set; } |
||||
|
|
||||
|
public bool Schemas { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,57 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Squidex.Infrastructure; |
||||
|
|
||||
|
namespace Migrate_01 |
||||
|
{ |
||||
|
public sealed class RebuildRunner |
||||
|
{ |
||||
|
private readonly Rebuilder rebuilder; |
||||
|
private readonly RebuildOptions rebuildOptions; |
||||
|
|
||||
|
public RebuildRunner(Rebuilder rebuilder, IOptions<RebuildOptions> rebuildOptions) |
||||
|
{ |
||||
|
Guard.NotNull(rebuilder, nameof(rebuilder)); |
||||
|
Guard.NotNull(rebuildOptions, nameof(rebuildOptions)); |
||||
|
|
||||
|
this.rebuilder = rebuilder; |
||||
|
this.rebuildOptions = rebuildOptions.Value; |
||||
|
} |
||||
|
|
||||
|
public async Task RunAsync(CancellationToken ct) |
||||
|
{ |
||||
|
if (rebuildOptions.Apps) |
||||
|
{ |
||||
|
await rebuilder.RebuildAppsAsync(ct); |
||||
|
} |
||||
|
|
||||
|
if (rebuildOptions.Schemas) |
||||
|
{ |
||||
|
await rebuilder.RebuildSchemasAsync(ct); |
||||
|
} |
||||
|
|
||||
|
if (rebuildOptions.Rules) |
||||
|
{ |
||||
|
await rebuilder.RebuildRulesAsync(ct); |
||||
|
} |
||||
|
|
||||
|
if (rebuildOptions.Assets) |
||||
|
{ |
||||
|
await rebuilder.RebuildAssetsAsync(ct); |
||||
|
} |
||||
|
|
||||
|
if (rebuildOptions.Contents) |
||||
|
{ |
||||
|
await rebuilder.RebuildContentAsync(ct); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue