示例#1
0
        public async Task RunStartupTasksAsync(CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            Logger.LogInformation("Running startup tasks");

            Resolve <ITaskManager>().AddTasks(GetExports <IScheduledTask>(false));

            ConfigurationManager.ConfigurationUpdated      += OnConfigurationUpdated;
            ConfigurationManager.NamedConfigurationUpdated += OnConfigurationUpdated;

            _mediaEncoder.SetFFmpegPath();

            Logger.LogInformation("ServerId: {ServerId}", SystemId);

            var entryPoints = GetExports <IServerEntryPoint>();

            cancellationToken.ThrowIfCancellationRequested();

            var stopWatch = new Stopwatch();

            stopWatch.Start();

            await Task.WhenAll(StartEntryPoints(entryPoints, true)).ConfigureAwait(false);

            Logger.LogInformation("Executed all pre-startup entry points in {Elapsed:g}", stopWatch.Elapsed);

            Logger.LogInformation("Core startup complete");
            CoreStartupHasCompleted = true;

            cancellationToken.ThrowIfCancellationRequested();

            stopWatch.Restart();

            await Task.WhenAll(StartEntryPoints(entryPoints, false)).ConfigureAwait(false);

            Logger.LogInformation("Executed all post-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
            stopWatch.Stop();
        }