/// <summary> /// Used to initialize service dependencies. This method is called before OnInitialize(), /// and should include common behavior for a family of services. /// When overridden on the family services base, it is recommended to mark it as sealed, /// to prevent concrete services from overriding the common behavior. /// </summary> /// <param name="kernel"></param> protected virtual void PreInitialize(IKernel kernel) { Kernel.Get <SystemInitializer.SystemInitializer>().Init(); CrashHandler = kernel.Get <ICrashHandler>(); CrashHandler.Init(OnCrash); IWorkloadMetrics workloadMetrics = kernel.Get <IWorkloadMetrics>(); workloadMetrics.Init(); var metricsInitializer = kernel.Get <IMetricsInitializer>(); metricsInitializer.Init(); }
protected override void OnStart() { Kernel = new StandardKernel(new NinjectSettings { ActivationCacheDisabled = true }); var env = HostEnvironment.CreateDefaultEnvironment(ServiceName, InfraVersion, Arguments); Kernel.Bind <IEnvironment>().ToConstant(env).InSingletonScope(); Kernel.Bind <CurrentApplicationInfo>().ToConstant(env.ApplicationInfo).InSingletonScope(); this.PreConfigure(Kernel, Arguments); this.Configure(Kernel); Kernel.Get <SystemInitializer>().Init(); CrashHandler = Kernel.Get <ICrashHandler>(); CrashHandler.Init(OnCrash); IWorkloadMetrics workloadMetrics = Kernel.Get <IWorkloadMetrics>(); workloadMetrics.Init(); var metricsInitializer = Kernel.Get <IMetricsInitializer>(); metricsInitializer.Init(); if (PerSiloGrainType != null) { Kernel.Get <OrleansConfigurationBuilder>().GetBuilder() .ConfigureServices(service => service.AddGrainService(PerSiloGrainType).AddSingleton(typeof(IPerSiloGrain), PerSiloGrainType)); } this.PreInitialize(Kernel); this.OnInitilize(Kernel); VerifyConfigurationsIfNeeded(Kernel.Get <MicrodotHostingConfig>(), Kernel.Get <ConfigurationVerificator>()); this.Warmup(Kernel); //don't move up the get should be after all the binding are done var log = Kernel.Get <ILog>(); this.requestListener = Kernel.Get <IRequestListener>(); this.requestListener.Listen(); log.Info(_ => _("start getting traffic", unencryptedTags: new { siloName = CurrentApplicationInfo.HostName })); }