public async Task CreateListener_HttpsDisabled_CreationSucceedsNoNeedForCertificate() { var endpointDefinition = Substitute.For <IServiceEndPointDefinition>(); using (var httpPort = DisposablePort.GetPort()) { endpointDefinition.HttpsPort.Returns(ci => httpPort.Port); endpointDefinition.HttpsPort.Returns(ci => null); // HTTPS disabled by a null HTTPS port var certificateLocator = Substitute.For <ICertificateLocator>(); certificateLocator.GetCertificate(Arg.Any <string>()).Throws <Exception>(); using (var listener = new HttpServiceListener(Substitute.For <IActivator>(), Substitute.For <IWorker>(), endpointDefinition, certificateLocator, Substitute.For <ILog>(), Enumerable.Empty <ICustomEndpoint>(), Substitute.For <IEnvironment>(), new JsonExceptionSerializer(Substitute.For <IStackTraceEnhancer>(), new JsonExceptionSerializationSettings(() => new ExceptionSerializationConfig(false, false))), new ServiceSchema(), () => new LoadShedding(), Substitute.For <IServerRequestPublisher>(), new CurrentApplicationInfo( nameof(HttpServiceListenerTests), Environment.UserName, System.Net.Dns.GetHostName()) )) { listener.Start(); } certificateLocator.DidNotReceive().GetCertificate(Arg.Any <string>()); } }
private async Task BootstrapInit(IProviderRuntime providerRuntime) { GrainTaskScheduler = TaskScheduler.Current; GrainFactory = providerRuntime.GrainFactory; providerRuntime.SetInvokeInterceptor(Interceptor); try { if (AfterOrleansStartup != null) { await AfterOrleansStartup(GrainFactory); } } catch (Exception ex) { BootstrapException = ex; throw; } try { HttpServiceListener.Start(); } catch (Exception ex) { BootstrapException = ex; Log.Error("Failed to start HttpServiceListener", exception: ex); throw; } }
/// <summary> /// Called when the service is started. This method first calls <see cref="CreateKernel"/>, configures it with /// infrastructure binding, calls <see cref="Configure"/> to configure additional bindings and settings, then /// start a <see cref="HttpServiceListener"/>. In most scenarios, you shouldn't override this method. /// </summary> protected override void OnStart() { Kernel = CreateKernel(); Kernel.Rebind <IActivator>().To <InstanceBasedActivator <TInterface> >().InSingletonScope(); Kernel.Rebind <IServiceInterfaceMapper>().To <IdentityServiceInterfaceMapper>().InSingletonScope().WithConstructorArgument(typeof(TInterface)); PreConfigure(Kernel); Configure(Kernel, Kernel.Get <BaseCommonConfig>()); PreInitialize(Kernel); OnInitilize(Kernel); Listener = Kernel.Get <HttpServiceListener>(); Listener.Start(); }
/// <summary> /// Called when the service is started. This method first calls <see cref="CreateKernel"/>, configures it with /// infrastructure binding, calls <see cref="Configure"/> to configure additional bindings and settings, then /// start a <see cref="HttpServiceListener"/>. In most scenarios, you shouldn't override this method. /// </summary> protected override void OnStart() { Kernel = CreateKernel(); Kernel.Bind <CurrentApplicationInfo>().ToConstant(new CurrentApplicationInfo(ServiceName, Arguments.InstanceName)).InSingletonScope(); Kernel.Rebind <IActivator>().To <InstanceBasedActivator <TInterface> >().InSingletonScope(); Kernel.Rebind <IServiceInterfaceMapper>().To <IdentityServiceInterfaceMapper>().InSingletonScope().WithConstructorArgument(typeof(TInterface)); PreConfigure(Kernel); Configure(Kernel, Kernel.Get <BaseCommonConfig>()); PreInitialize(Kernel); OnInitilize(Kernel); //don't move up the get should be after all the binding are done var log = Kernel.Get <ILog>(); Listener = Kernel.Get <HttpServiceListener>(); Listener.Start(); Listener.StartGettingTraffic(); log.Info(_ => _("start getting traffic", unencryptedTags: new { siloName = CurrentApplicationInfo.HostName })); }