コード例 #1
0
        public static async Task StartupAsync(IServiceProvider serviceProvider)
        {
            ILoggerFactory loggerFactory = serviceProvider.GetRequiredService <ILoggerFactory>();

            ExecutionEnvironment     environment   = serviceProvider.GetRequiredService <ExecutionEnvironment>();
            ApplicationConfiguration configuration = serviceProvider.GetRequiredService <ApplicationConfiguration>();

            Logging.InitializeLogging(environment: environment,
                                      loggerFactory: loggerFactory,
                                      configuration: configuration.LoggingConfiguration,
                                      version: configuration.Version,
                                      tenant: configuration.Tenant);

            // resolve a logger
            ILogger <Startup> logger = loggerFactory.CreateLogger <Startup>();

            logger.LogInformation(new EventId(id: 27), message: "Starting Labs Scaling Ethereum Server");

            EthereumServices.ConfigureGasPriceRecommendationWatcher(serviceProvider: serviceProvider);
            EthereumServices.ConfigureEventProcessing(serviceProvider: serviceProvider);

            try
            {
                await EthereumServices.ClearEventProcessingDatabaseLocksAsync(serviceProvider : serviceProvider, logger : logger);

                await ObjectLockingServices.ClearLocksAsync(serviceProvider : serviceProvider, logger : logger);

                await EnableNetworksAsync(serviceProvider : serviceProvider, logger : logger);

                IConfigurationRoot ethereumConfigurationRoot = EthereumServices.GetEthereumConfiguration(ApplicationConfigLocator.ConfigurationFilesPath);

                IEthereumAccountsMigrator ethereumAccountsMigrator = serviceProvider.GetRequiredService <IEthereumAccountsMigrator>();

                // Must do all of these BEFORE starting all services.
                await ethereumAccountsMigrator.ConfigureEthereumNetworkSettingsAsync(services : serviceProvider,
                                                                                     configuration : ethereumConfigurationRoot,
                                                                                     fateChannelTokenFundingSourceAction : (_, _, _) => { });

                logger.LogInformation(new EventId(id: 28), message: "Labs Scaling Ethereum Services Started");
            }
            catch (Exception exception)
            {
                logger.LogError(new EventId(id: exception.HResult), exception: exception, message: "Failed to start Labs Scaling Ethereum Server services");

                throw;
            }
        }
コード例 #2
0
 /// <summary>
 ///     Called when the application is shutting down
 /// </summary>
 public static Task ShutdownAsync()
 {
     // Ensure any locks that were held are closed by the server on shutdown.
     return(Task.WhenAll(ObjectLockingServices.ClearLocksAsync(), EthereumServices.ClearEventProcessingDatabaseLocksAsync()));
 }