public void Start() { _Log.Info("WebServer is starting..."); try { // TODO Build optional SSL support with certificates SuaveHttp.Protocol protocol = SuaveHttp.Protocol.HTTP; FSharpList <SuaveHttp.HttpBinding> bindings = ListModule.OfSeq(_ListenAddresses.Select(ep => new SuaveHttp.HttpBinding(protocol, new Suave.Sockets.SocketBinding(ep.Address, (ushort)ep.Port)))); var suaveConfig = SuaveWeb.defaultConfig.withCancellationToken(_CancellationTokenSource.Token).withBindings(bindings); GlobalHost.DependencyResolver.Register(typeof(RemoteHub), () => new RemoteHub(_RemoteControlService, this)); AppBootstrapper bootstrapper = new AppBootstrapper(_RemoteControlService); NancyOptions nancyOptions = new NancyOptions(); nancyOptions.Bootstrapper = bootstrapper; AppBuilder appBuilder = new AppBuilder(); appBuilder.MapSignalR(); appBuilder.UseNancy(nancyOptions); var owin = appBuilder.Build(); var app = Suave.Owin.OwinAppModule.OfAppFunc("", owin); var startAction = SuaveWeb.startWebServerAsync(suaveConfig, app); FSharpAsync.Start(startAction.Item2, FSharpOption <CancellationToken> .Some(_CancellationTokenSource.Token)); FSharpAsync.StartAsTask(startAction.Item1, FSharpOption <TaskCreationOptions> .Some(TaskCreationOptions.None), FSharpOption <CancellationToken> .None).ContinueWith((started) => { _Log.Info("WebServer is running."); Status = ServerStatus.Ready; }); } catch (Exception ex) { _Log.Error(string.Format("Failed to start web server: {0}", ex.Message), ex); Status = ServerStatus.Stopped; Error = ex; } }
public Task StartPipeline() { projector = StartProjector(); FSharpFunc <Unit, IChangeFeedObserver> createObserver = new createObserver(projector); FSharpOption <int> maxDocuments = ConfigureMaxDocuments(); FSharpOption <TimeSpan> lagFrequency = ConfigureLagFrequency(); FSharpAsync <Unit> pipeline = CosmosSource.Run( Log.Logger, _discovery, _connector.ClientOptions, _source, _aux, _leaseId, _startFromTail, createObserver, maxDocuments: maxDocuments, lagReportFreq: lagFrequency, null); FSharpAsync.Start(pipeline, null); return(Task.CompletedTask); }