public EmbeddedFubuMvcServer(FubuRuntime runtime, string physicalPath = null, int port = 5500) { if (port <= 0) { port = PortFinder.FindPort(5500); } _runtime = runtime; _services = _runtime.Factory; // before anything else, make sure there is no server on the settings // We're doing this hokey-pokey to ensure that things don't get double // disposed var settings = runtime.Factory.Get <KatanaSettings>(); var peer = settings.EmbeddedServer; if (peer == null) { startAllNew(runtime, physicalPath, port); } else { takeOverFromExistingServer(peer, settings); } buildEndpointDriver(port); }
public void finder_default_end_index() { var finder = new PortFinder(200); finder.StartIndex.ShouldBe(200); finder.EndIndex.ShouldBe(PortFinder.LastPort); }
public IDisposable LaunchRunner() { var middleware = new TopicMiddleware(this, _container.GetInstance <IHtmlGenerator>(), _settings); var webSockets = new WebSocketsHandler(); _refresher = new BrowserRefresher(webSockets); var port = PortFinder.FindPort(5000); _settings.WebsocketAddress = $"ws://localhost:{port}"; _container.Inject <IBrowserRefresher>(_refresher); StartScanning(); var host = startHost(port, webSockets, middleware); _topicWatcher = new TopicFileWatcher(_settings, this); _topicWatcher.StartWatching(_refresher); return(host); }
public void static_finder_throws_exception_on_index_out_of_range() { Should.Throw <ArgumentOutOfRangeException>(() => PortFinder.FindNextLocalOpenPort(PortFinder.FirstPort - 1)); Should.Throw <ArgumentOutOfRangeException>(() => PortFinder.FindNextLocalOpenPort(PortFinder.LastPort + 1)); Should.Throw <ArgumentOutOfRangeException>(() => PortFinder.FindNextLocalOpenPort(PortFinder.FirstPort - 1, PortFinder.LastPort)); Should.Throw <ArgumentOutOfRangeException>(() => PortFinder.FindNextLocalOpenPort(PortFinder.FirstPort, PortFinder.LastPort + 1)); }
public static Harness Run(Action <FubuRegistry> configure, IContainer container) { var applicationDirectory = GetApplicationDirectory(); FubuMvcPackageFacility.PhysicalRootPath = applicationDirectory; var application = new FubuKayakApplication(new SimpleSource(configure, container)); var port = PortFinder.FindPort(_port++); var reset = new ManualResetEvent(false); FubuRuntime runtime = null; ThreadPool.QueueUserWorkItem(o => { // Need to make this capture the package registry failures cleanly application.RunApplication(port, r => { runtime = r; reset.Set(); }); }); reset.WaitOne(); var root = "http://localhost:" + port; return(new Harness(runtime, application, root)); // Need to get the runtime }
public DocProject(DocSettings settings) { Port = PortFinder.FindPort(5050); BaseAddress = "http://localhost:" + Port; _settings = settings; ReadTopics(); _container = new Container(_ => { _.For <ISampleCache>().Use(this); _.For <DocProject>().Use(this); _.AddRegistry <SampleRegistry>(); _.AddRegistry <TransformationRegistry>(); _.For(typeof(IUrlResolver)).Use(settings.UrlResolverType()); _.ForSingletonOf <ICommandUsageCache>().Use <CommandUsageCache>(); _.For <DocSettings>().Use(settings); _.For <Topic>().Use(Topic); }); }
public IClientConnector Start(IApplication application) { var port = PortFinder.FindPort(5000); _application = application; BaseAddress = "http://localhost:" + port; var webSockets = new WebSocketsHandler(); _commands = new CommandRunner(application); Client = new ClientConnector(webSockets, _commands.HandleJson) { WebSocketsAddress = $"ws://127.0.0.1:{port}" }; startWebServer(port, webSockets); #if DEBUG _watcher = new AssetFileWatcher(Client); _watcher.Start(_input); #endif return(Client); }
public void finder_default_start_and_end_indicies() { var finder = new PortFinder(); finder.StartIndex.ShouldBe(PortFinder.FirstPort); finder.EndIndex.ShouldBe(PortFinder.LastPort); }
public IClientConnector Start(IApplication application, WebApplicationConfiguration additionalConfiguration = null) { var port = additionalConfiguration?.Port ?? PortFinder.FindPort(5000); var hostname = additionalConfiguration?.Hostname ?? "localhost"; _application = application; BaseAddress = $"http://{hostname}:{port}"; var webSockets = new WebSocketsHandler(); _commands = new CommandRunner(application); Client = new ClientConnector(webSockets, _commands.HandleJson) { WebSocketsAddress = $"ws://{hostname}:{port}" }; startWebServer(hostname, port, webSockets); #if DEBUG _watcher = new AssetFileWatcher(Client); _watcher.Start(_input); #endif return(Client); }
public ClientConnector(ILogger logger, IRemoteController controller, IEnumerable <ICommand> commands) { _logger = logger; _controller = controller; _commands = commands; _port = PortFinder.FindPort(8200); }
public MonitoredNodeGroup() { _port = PortFinder.FindPort(5500); AlterSettings <KatanaSettings>(_ => { _.AutoHostingEnabled = true; _.Port = _port; }); Services(_ => { _.ReplaceService <ISchedulePersistence, RavenDbSchedulePersistence>(); _.ReplaceService <ISubscriptionPersistence, RavenDbSubscriptionPersistence>(); }); ReplaceSettings(RavenDbSettings.InMemory()); Import <MonitoredTransportRegistry>(); container = new Container(_ => { _.ForSingletonOf <MonitoredNodeGroup>().Use(this); }); _runtime = FubuApplication.For(this).StructureMap(container).Bootstrap(); _runtime.Factory.Get <ChannelGraph>().Name = "Monitoring"; _subscriptions = _runtime.Factory.Get <ISubscriptionPersistence>(); _schedules = _runtime.Factory.Get <ISchedulePersistence>(); _store = _runtime.Factory.Get <IDocumentStore>(); }
public static void Run(Action <EndpointDriver> action) { using (var server = EmbeddedFubuMvcServer.For <HarnessApplication>(port: PortFinder.FindPort(5502))) { action(server.Endpoints); } }
private bool tryStart() { var increment = new Random(5).Next(1, 50); _port = PortFinder.FindPort(_port + increment); _webSocketsAddress = "ws://" + _host + ":" + _port; try { _server = new WebSocketServer(_webSocketsAddress); _server.Start(socket => { socket.OnOpen = () => _sockets.Add(socket); socket.OnClose = () => _sockets.Remove(socket); socket.OnMessage = HandleJson; }); Console.WriteLine("Publishing client messages via web sockets at " + _webSocketsAddress); return(true); } catch (Exception) { Console.WriteLine("Failed to open web sockets to " + _webSocketsAddress + ", trying another port"); return(false); } }
public void ThrowsExceptionWhenIndexIsOutOfRange() { Should.Throw <ArgumentOutOfRangeException>(() => PortFinder.FindNextLocalOpenPort(PortFinder.FirstPort - 1)); Should.Throw <ArgumentOutOfRangeException>(() => PortFinder.FindNextLocalOpenPort(PortFinder.LastPort + 1)); Should.Throw <ArgumentOutOfRangeException>(() => PortFinder.FindNextLocalOpenPort(PortFinder.FirstPort - 1, PortFinder.LastPort)); Should.Throw <ArgumentOutOfRangeException>(() => PortFinder.FindNextLocalOpenPort(PortFinder.FirstPort, PortFinder.LastPort + 1)); }
public void DefaultsStartAndEndIndicies() { var finder = new PortFinder(); finder.StartIndex.ShouldBe(PortFinder.FirstPort); finder.EndIndex.ShouldBe(PortFinder.LastPort); }
public void Initialize(Type applicationType, int port, string physicalPath) { _applicationSource = Activator.CreateInstance(applicationType).As <IApplicationSource>(); _port = PortFinder.FindPort(port); _physicalPath = physicalPath; StartUp(); }
private bool FixPort(CommandLineOptions options) { if (options.Port == 0) { options.Port = PortFinder.GetFreePort(); } return(true); }
public void FindsOpenPortUsingCustomStartIndex() { var start = int.Parse(PortFinder.FindNextLocalOpenPort()) + 1; var port = PortFinder.FindNextLocalOpenPort(start); port.ShouldNotBeNull(); int.Parse(port).ShouldBeGreaterThanOrEqualTo(start); }
public static void Start() { FubuMvcPackageFacility.PhysicalRootPath = GetRootDirectory(); int port = PortFinder.FindPort(5501); _server = EmbeddedFubuMvcServer.For <HarnessApplication>(GetRootDirectory(), port); }
public ClientConnector(ILogger logger, IRemoteController controller, IEnumerable <ICommand> commands) { _logger = logger; _controller = controller; _commands = commands; _host = controller.WebSocketAddress.IsNotEmpty() ? controller.WebSocketAddress : "127.0.0.1"; _port = PortFinder.FindPort(8200); }
public void static_finder_finds_open_port_using_start() { var start = int.Parse(PortFinder.FindNextLocalOpenPort()) + 1; var port = PortFinder.FindNextLocalOpenPort(start); port.ShouldNotBeNull(); int.Parse(port).ShouldBeGreaterThanOrEqualTo(start); }
public override void SetUp() { var receiverPort = PortFinder.FindPort(3340); var senderPort = PortFinder.FindPort(3370); var publishingUri = $"tcp://localhost:{receiverPort}/durable"; var senderRegistry = new JasperOptions(); senderRegistry.Handlers .DisableConventionalDiscovery() .IncludeType <CascadeReceiver>() .IncludeType <ScheduledMessageHandler>(); senderRegistry.Extensions.UseMessageTrackingTestingSupport(); senderRegistry.Endpoints.Publish(x => { x.Message <TriggerMessage>(); x.Message <ItemCreated>(); x.Message <Question>(); x.Message <ScheduledMessage>(); x.ToPort(receiverPort).Durably(); }); senderRegistry.Endpoints.ListenAtPort(senderPort).Durable(); configureSender(senderRegistry); theSender = JasperHost.For(senderRegistry); theSender.RebuildMessageStorage(); var receiverRegistry = new JasperOptions(); receiverRegistry.Extensions.UseMessageTrackingTestingSupport(); receiverRegistry.Handlers.DisableConventionalDiscovery() .IncludeType <TTriggerHandler>() .IncludeType <TItemCreatedHandler>() .IncludeType <QuestionHandler>() .IncludeType <ScheduledMessageHandler>(); receiverRegistry.Endpoints.ListenAtPort(receiverPort).Durable(); receiverRegistry.Extensions.UseMessageTrackingTestingSupport(); configureReceiver(receiverRegistry); theReceiver = JasperHost.For(receiverRegistry); theReceiver.RebuildMessageStorage(); initializeStorage(theSender, theReceiver); }
public IApplicationUnderTest Start(ApplicationSettings settings, FubuRuntime runtime, IBrowserLifecycle lifecycle) { var port = PortFinder.FindPort(settings.Port); _server = new EmbeddedFubuMvcServer(runtime, settings.PhysicalPath, port); settings.RootUrl = _server.BaseAddress; return(new ApplicationUnderTest(runtime, settings, lifecycle)); }
public static void Start() { FubuMvcPackageFacility.PhysicalRootPath = GetRootDirectory(); _server = FubuApplication.For <HarnessRegistry>() .StructureMap(new Container()) .RunEmbedded(GetRootDirectory(), PortFinder.FindPort(5500)); }
public WebSocketServer() { _webSockets = new WebSocketsHandler { Received = receiveJson }; Port = PortFinder.FindPort(5250); }
public override void SetUp() { theTracker = new Jasper.Messaging.Tracking.MessageTracker(); var receiverPort = PortFinder.FindPort(3340); var senderPort = PortFinder.FindPort(3370); var publishingUri = $"tcp://localhost:{receiverPort}/durable"; var senderRegistry = new JasperRegistry(); senderRegistry.Handlers .DisableConventionalDiscovery() .IncludeType <CascadeReceiver>() .IncludeType <ScheduledMessageHandler>(); senderRegistry.Services.AddSingleton(theTracker); senderRegistry.Publish.Message <TriggerMessage>().To(publishingUri); senderRegistry.Publish.Message <ItemCreated>().To(publishingUri); senderRegistry.Publish.Message <Question>().To(publishingUri); senderRegistry.Publish.Message <ScheduledMessage>().To(publishingUri); senderRegistry.Transports.DurableListenerAt(senderPort); configureSender(senderRegistry); theSender = JasperHost.For(senderRegistry); theSender.RebuildMessageStorage(); var receiverRegistry = new JasperRegistry(); receiverRegistry.Handlers.DisableConventionalDiscovery() .IncludeType <TTriggerHandler>() .IncludeType <TItemCreatedHandler>() .IncludeType <QuestionHandler>() .IncludeType <ScheduledMessageHandler>(); receiverRegistry.Transports.DurableListenerAt(receiverPort); receiverRegistry.Handlers.Worker("items").IsDurable() .HandlesMessage <ItemCreated>(); receiverRegistry.Services.AddSingleton(theTracker); configureReceiver(receiverRegistry); theReceiver = JasperHost.For(receiverRegistry); theReceiver.RebuildMessageStorage(); initializeStorage(theSender, theReceiver); }
public void SetUp() { _runner.RunBottles("init src/TestPackage1 pak1"); _runner.RunBottles("link src/FubuMVC.Core.Assets.IntegrationTesting pak1"); _server = FubuApplication.DefaultPolicies() .StructureMap(new Container()) .RunEmbedded(port: PortFinder.FindPort(5505)); }
public void Initialize(Type applicationType, int port, string physicalPath) { _applicationSource = Activator.CreateInstance(applicationType).As <IApplicationSource>(); _port = PortFinder.FindPort(port); _physicalPath = physicalPath; var assembly = typeof(EmbeddedFubuMvcServer).Assembly; StartUp(); }
public void static_finder_finds_port_when_start_and_end_index_are_inverted() { const int start = 4000; const int end = 5000; var port = int.Parse(PortFinder.FindNextLocalOpenPort(end, start)); port.ShouldBeGreaterThanOrEqualTo(start); port.ShouldBeLessThanOrEqualTo(end); }
public void static_finder_finds_open_port_using_start_and_end() { const int start = 5000; const int end = 10000; var port = int.Parse(PortFinder.FindNextLocalOpenPort(start, end)); port.ShouldBeGreaterThanOrEqualTo(start); port.ShouldBeLessThanOrEqualTo(end); }