示例#1
0
        private async Task RunAsyncInternal()
        {
            var stopwatch = Stopwatch.StartNew();

            try
            {
                _container.RegisterSingleton <IController>(() => this);
                _container.RegisterServices();
                _options.ContainerConfigurator?.ConfigureContainer(_container);
                _container.Verify();

                _log = _container.GetInstance <ILogService>().CreatePublisher(nameof(Controller));

                _container.GetInstance <IInterruptMonitorService>().RegisterInterrupts();
                _container.GetInstance <IDeviceRegistryService>().RegisterDevices();
                _container.GetInstance <IRemoteSocketService>().RegisterRemoteSockets();

                _container.StartupServices(_log);
                _container.ExposeRegistrationsToApi();

                await TryConfigureAsync();

                StartupCompleted?.Invoke(this, new StartupCompletedEventArgs(stopwatch.Elapsed));

                _container.GetInstance <IScriptingService>().TryExecuteStartupScripts();
            }
            catch (Exception exception)
            {
                StartupFailed?.Invoke(this, new StartupFailedEventArgs(stopwatch.Elapsed, exception));
                _deferral?.Complete();
            }
        }
示例#2
0
        public void OnStartupCompleted()
        {
            _systemStatusService.Set("startup.duration", DateTime.Now - _creationTimestamp);

            PublishBootedNotification();

            StartupCompleted?.Invoke(this, EventArgs.Empty);

            _logger.LogInformation("Startup completed.");
        }
示例#3
0
 private void OnStartupCompleted(SwApplication app)
 {
     try
     {
         StartupCompleted?.Invoke(this);
     }
     catch (Exception ex)
     {
         Logger.Log(ex);
     }
 }
示例#4
0
        private void Startup()
        {
            try
            {
                var stopwatch = Stopwatch.StartNew();

                RegisterServices();
                StartHttpServer();

                _container.StartupServices(_log);
                _container.ExposeRegistrationsToApi();

                TryConfigure();

                StartupCompleted?.Invoke(this, EventArgs.Empty);
                stopwatch.Stop();

                _container.GetInstance <IApiDispatcherService>().ConfigurationRequested += (s, e) =>
                {
                    var controllerSettings = _container.GetInstance <ISettingsService>().GetSettings <ControllerSettings>();
                    e.ApiContext.Result["Controller"] = JObject.FromObject(controllerSettings);
                };

                _log.Info("Startup completed after " + stopwatch.Elapsed);

                _container.GetInstance <ISystemInformationService>().Set("Health/StartupDuration", stopwatch.Elapsed);
                _container.GetInstance <ISystemInformationService>().Set("Health/StartupTimestamp", _container.GetInstance <IDateTimeService>().Now);

                _container.GetInstance <ITimerService>().Run();
            }
            catch (Exception exception)
            {
                _log?.Error(exception, "Failed to initialize.");
                StartupFailed?.Invoke(this, EventArgs.Empty);
            }
            finally
            {
                Shutdown?.Invoke(this, EventArgs.Empty);
                _deferral?.Complete();
            }
        }
示例#5
0
        private void Startup()
        {
            try
            {
                var stopwatch = Stopwatch.StartNew();

                SetupLogger();

                Log.Info("Starting...");

                RegisterServices();
                TryConfigure();

                StartupServices();
                ExposeRegistrationsToApi();
                StartHttpServer();

                StartupCompleted?.Invoke(this, EventArgs.Empty);
                stopwatch.Stop();

                Log.Info("Startup completed after " + stopwatch.Elapsed);

                _container.GetInstance <ISystemInformationService>().Set("Health/StartupDuration", stopwatch.Elapsed);
                _container.GetInstance <ISystemInformationService>().Set("Health/StartupTimestamp", _container.GetInstance <IDateTimeService>().Now);

                _container.GetInstance <ITimerService>().Run();
            }
            catch (Exception exception)
            {
                Log.Error(exception, "Failed to initialize.");
                StartupFailed?.Invoke(this, EventArgs.Empty);
            }
            finally
            {
                Shutdown?.Invoke(this, EventArgs.Empty);
                _deferral?.Complete();
            }
        }
示例#6
0
 private void OnStartupCompleted(object sender, EventArgs eventArgs)
 {
     _notificationService.CreateInformation(SystemEventNotification.Booted);
     StartupCompleted?.Invoke(this, EventArgs.Empty);
 }
示例#7
0
 private void OnStartupCompleted(SwApplication app)
 {
     m_Application.FirstStartupCompleted -= OnStartupCompleted;
     StartupCompleted?.Invoke(this);
 }
示例#8
0
 public void RaiseStartupCompleted()
 {
     StartupCompleted?.Invoke(this, new StartupCompletedEventArgs(TimeSpan.Zero));
 }