예제 #1
0
파일: Controller.cs 프로젝트: tuanth/HA4IoT
        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
파일: Controller.cs 프로젝트: sindab/HA4IoT
        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
파일: SwAddInEx.cs 프로젝트: persadewh/xcad
 private void OnStartupCompleted(SwApplication app)
 {
     m_Application.FirstStartupCompleted -= OnStartupCompleted;
     StartupCompleted?.Invoke(this);
 }
예제 #8
0
 public void RaiseStartupCompleted()
 {
     StartupCompleted?.Invoke(this, new StartupCompletedEventArgs(TimeSpan.Zero));
 }