public Task Start() { return(Task.Factory.StartNew(() => { _runner = _source(); _runner.WaitForMessage <LoaderStarted>(); })); }
public void overriding_the_configuration_file() { // SAMPLE: override-config-file var runner = new RemoteServiceRunner(x => { x.Setup.ConfigurationFile = "Web.config"; }); // ENDSAMPLE }
public void open_to_a_parallel_directory() { // SAMPLE: parallel-service var runner = new RemoteServiceRunner(x => { x.UseParallelServiceDirectory("Service1"); }); // ENDSAMPLE }
public void start_with_only_the_folder_name_with_an_IApplicationLoader() { var servicePath = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory().AppendPath("ApplicationLoaderService"); using (var runner = new RemoteServiceRunner(servicePath)) { runner.WaitForMessage <LoaderStarted>().LoaderTypeName.ShouldContain("MyApplicationLoader"); } }
public void start_with_a_parallel_folder() { using (var runner = new RemoteServiceRunner(x => { x.UseParallelServiceDirectory("ApplicationLoaderService"); })) { runner.WaitForMessage <LoaderStarted>().LoaderTypeName.ShouldContain("MyApplicationLoader"); } }
public void run_a_specific_bootstrapper() { using (var runner = RemoteServiceRunner.For <SampleBootstrapper>()) { runner.WaitForServiceToStart <SampleService.SampleService>(); runner.WaitForServiceToStart <SampleService.RemoteService>(); runner.Started.Any().ShouldBeTrue(); } }
public void start_with_only_the_folder_name_with_an_IActivator() { var servicePath = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory().AppendPath("SampleService"); using (var runner = new RemoteServiceRunner(servicePath)) { runner.WaitForServiceToStart <SampleService.SampleService>(); runner.Started.Any().ShouldBeTrue(); } }
public void load_assemblies() { // SAMPLE: require-assemblies var runner = new RemoteServiceRunner(x => { // This line will copy the MyAssembly.dll assembly to the // remote path x.RequireAssembly("MyAssembly"); }); // ENDSAMPLE }
public void load_assemblies() { // SAMPLE: require-assemblies var runner = new RemoteServiceRunner(x => { // This line of code will copy the Bottles.dll assembly // into the remote AppDomain location x.RequireAssemblyContainingType <Bottles.IPackageFacility>(); x.RequireAssembly("MyAssembly"); }); // ENDSAMPLE }
public void Start(object listener, Action <RemoteDomainExpression> configuration = null) { _runner = RemoteServiceRunner.For <RemoteFubuMvcBootstrapper>(x => { x.RequireAssemblyContainingType <EmbeddedFubuMvcServer>(AssemblyCopyMode.SemVerCompatible); x.RequireAssemblyContainingType <RemoteFubuMvcProxy>(AssemblyCopyMode.SemVerCompatible); x.RequireAssemblyContainingType <RemoteServiceRunner>(AssemblyCopyMode.SemVerCompatible); x.RequireAssemblyContainingType <Owin.IAppBuilder>(); x.RequireAssemblyContainingType <IActivator>(); // Bottles x.RequireAssemblyContainingType <IModelBinder>(); // FubuCore x.RequireAssemblyContainingType <FubuApplication>(AssemblyCopyMode.SemVerCompatible); // FubuMVC.Core x.RequireAssemblyContainingType <HtmlTag>(AssemblyCopyMode.SemVerCompatible); // HtmlTags x.RequireAssemblyContainingType <FubuCsProjFile.CodeFile>(); // FubuCsProjFile just to keep it from whining x.RequireAssemblyContainingType <DiagnosticChainsSource>(AssemblyCopyMode.SemVerCompatible); x.RequireAssemblyContainingType <SparkViewEngine>(AssemblyCopyMode.SemVerCompatible); x.RequireAssemblyContainingType <SparkTemplate>(AssemblyCopyMode.SemVerCompatible); x.RequireAssembly("Microsoft.Owin.Hosting"); x.RequireAssembly("Microsoft.Owin.Host.HttpListener"); x.RequireAssembly("Microsoft.Owin"); x.RequireAssembly("Owin"); x.ServiceDirectory = _request.DirectoryFlag; if (_request.ConfigFlag.IsNotEmpty()) { x.Setup.ConfigurationFile = _request.ConfigFlag; } x.Setup.PrivateBinPath = _request.DetermineBinPath(); if (configuration != null) { configuration(x); } Console.WriteLine("Assembly bin path is " + x.Setup.PrivateBinPath); Console.WriteLine("The configuration file is " + x.Setup.ConfigurationFile); }); _runner.WaitForServiceToStart <RemoteFubuMvcBootstrapper>(); _runner.Messaging.AddListener(listener); _runner.SendRemotely(new StartApplication { ApplicationName = _request.ApplicationFlag, PhysicalPath = _request.DirectoryFlag, PortNumber = PortFinder.FindPort(_request.PortFlag), UseProductionMode = _request.ProductionModeFlag, AutoRefreshWebSocketsAddress = _request.AutoRefreshWebSocketsAddress }); }
public void Start(object listener, Action<RemoteDomainExpression> configuration = null) { _runner = RemoteServiceRunner.For<RemoteFubuMvcBootstrapper>(x => { x.RequireAssemblyContainingType<EmbeddedFubuMvcServer>(AssemblyCopyMode.SemVerCompatible); x.RequireAssemblyContainingType<RemoteFubuMvcProxy>(AssemblyCopyMode.SemVerCompatible); x.RequireAssemblyContainingType<RemoteServiceRunner>(AssemblyCopyMode.SemVerCompatible); x.RequireAssemblyContainingType<Owin.IAppBuilder>(); x.RequireAssemblyContainingType<IActivator>(); // Bottles x.RequireAssemblyContainingType<IModelBinder>(); // FubuCore x.RequireAssemblyContainingType<StringToken>(); // FubuLocalization x.RequireAssemblyContainingType<FubuApplication>(); // FubuMVC.Core x.RequireAssemblyContainingType<FubuCsProjFile.CodeFile>(); // FubuCsProjFile just to keep it from whining x.RequireAssembly("Newtonsoft.Json"); x.RequireAssembly("FubuMVC.OwinHost"); x.RequireAssembly("Microsoft.Owin.Hosting"); x.RequireAssembly("Microsoft.Owin.Host.HttpListener"); x.RequireAssembly("Microsoft.Owin"); x.RequireAssembly("Owin"); x.ServiceDirectory = _request.DirectoryFlag; if (_request.ConfigFlag.IsNotEmpty()) { x.Setup.ConfigurationFile = _request.ConfigFlag; } x.Setup.PrivateBinPath = _request.DetermineBinPath(); if (configuration != null) { configuration(x); } Console.WriteLine("Assembly bin path is " + x.Setup.PrivateBinPath); Console.WriteLine("The configuration file is " + x.Setup.ConfigurationFile); }); _runner.WaitForServiceToStart<RemoteFubuMvcBootstrapper>(); _runner.Messaging.AddListener(listener); _runner.SendRemotely(new StartApplication { ApplicationName = _request.ApplicationFlag, PhysicalPath = _request.DirectoryFlag, PortNumber = PortFinder.FindPort(_request.PortFlag), UseProductionMode = _request.ProductionModeFlag }); }
public void control_appdomain_setup() { // SAMPLE: appdomain-setup var runner = new RemoteServiceRunner(x => { // ShadowCopyFiles should be either "true" or "false" x.Setup.ShadowCopyFiles = true.ToString(); // RemoteServiceRunner makes some guesses about the // PrivateBinPath based on the folders it sees, // but once in a while you may want to override // the bin path x.Setup.PrivateBinPath = "bin"; }); // ENDSAMPLE }
public void Start(object listener, Action<RemoteDomainExpression> configuration = null) { _runner = RemoteServiceRunner.For<RemoteFubuMvcBootstrapper>(x => { x.RequireAssemblyContainingType<RemoteFubuMvcProxy>(AssemblyCopyMode.SemVerCompatible); x.RequireAssemblyContainingType<IAppBuilder>(); x.RequireAssemblyContainingType<IModelBinder>(); // FubuCore x.RequireAssemblyContainingType<FubuRuntime>(AssemblyCopyMode.SemVerCompatible); // FubuMVC.Core x.RequireAssemblyContainingType<HtmlTag>(AssemblyCopyMode.SemVerCompatible); // HtmlTags x.RequireAssembly("Microsoft.Owin.Hosting"); x.RequireAssembly("Microsoft.Owin.Host.HttpListener"); x.RequireAssembly("Microsoft.Owin"); x.RequireAssembly("Owin"); x.ServiceDirectory = _request.DirectoryFlag; if (_request.ConfigFlag.IsNotEmpty()) { x.Setup.ConfigurationFile = _request.ConfigFlag; } x.Setup.PrivateBinPath = _request.DetermineBinPath(); if (configuration != null) { configuration(x); } Console.WriteLine("Assembly bin path is " + x.Setup.PrivateBinPath); Console.WriteLine("The configuration file is " + x.Setup.ConfigurationFile); }); _runner.WaitForServiceToStart<RemoteFubuMvcBootstrapper>(); _runner.Messaging.AddListener(listener); _runner.SendRemotely(new StartApplication { ApplicationName = _request.RegistryFlag, PhysicalPath = _request.DirectoryFlag, PortNumber = PortFinder.FindPort(_request.PortFlag), Mode = _request.ModeFlag, AutoRefreshWebSocketsAddress = _request.AutoRefreshWebSocketsAddress }); }
public void Start(object listener, Action <RemoteDomainExpression> configuration = null) { _runner = RemoteServiceRunner.For <RemoteFubuMvcBootstrapper>(x => { x.RequireAssemblyContainingType <EmbeddedFubuMvcServer>(); x.RequireAssemblyContainingType <RemoteFubuMvcProxy>(); x.RequireAssemblyContainingType <RemoteServiceRunner>(); x.RequireAssemblyContainingType <Owin.IAppBuilder>(); x.RequireAssemblyContainingType <IActivator>(); // Bottles x.RequireAssemblyContainingType <IModelBinder>(); // FubuCore x.RequireAssemblyContainingType <StringToken>(); // FubuLocalization x.RequireAssemblyContainingType <FubuApplication>(); // FubuMVC.Core x.RequireAssemblyContainingType <FubuCsProjFile.CodeFile>(); // FubuCsProjFile just to keep it from whining x.RequireAssembly("Owin.Extensions"); x.RequireAssembly("Newtonsoft.Json"); x.RequireAssembly("FubuMVC.OwinHost"); x.RequireAssembly("Microsoft.Owin.Hosting"); x.RequireAssembly("Microsoft.Owin.Host.HttpListener"); x.RequireAssembly("Microsoft.Owin"); x.RequireAssembly("Owin"); x.ServiceDirectory = _request.DirectoryFlag; x.Setup.PrivateBinPath = _request.DetermineBinPath(); if (configuration != null) { configuration(x); } Console.WriteLine("Assembly bin path is " + x.Setup.PrivateBinPath); }); _runner.WaitForServiceToStart <RemoteFubuMvcBootstrapper>(); _runner.Messaging.AddListener(listener); _runner.SendRemotely(new StartApplication { ApplicationName = _request.ApplicationFlag, PhysicalPath = _request.DirectoryFlag, PortNumber = PortFinder.FindPort(_request.PortFlag), UseProductionMode = _request.ProductionModeFlag }); }
public void loading_a_custom_application_loader() { // SAMPLE: bootstrap-custom-loader var runner = RemoteServiceRunner.For <IApplicationLoader>(x => { // more AppDomain configuration }); // -- or -- runner = new RemoteServiceRunner(x => { // Can be the assembly qualified name of either: // 1. An IApplicationLoader class // 2. An IApplicationSource<,> class // 3. An IBootstrapper class x.BootstrapperName = "MyLib.AppLoader, MyLib"; }); // ENDSAMPLE }
public void coordinate_message_history_via_remote_service() { using (var runner = RemoteServiceRunner.For <SampleBootstrapper>()) { runner.WaitForServiceToStart <SampleService.SampleService>(); runner.WaitForServiceToStart <SampleService.RemoteService>(); MessageHistory.ConnectRemoteListeners(runner); var foo = new Foo(); GlobalMessageTracking.SentMessage(foo); GlobalMessageTracking.Messaging.WaitForMessage <AllMessagesComplete>(() => runner.SendRemotely(foo), 60000) .ShouldNotBeNull(); } }
public void coordinate_message_history_via_remote_service_and_clear_data_does_not_remove_listeners() { using (var runner = RemoteServiceRunner.For <SampleBootstrapper>()) { runner.WaitForServiceToStart <SampleService.SampleService>(); runner.WaitForServiceToStart <SampleService.RemoteService>(); MessageHistory.StartListening(runner); MessageHistory.ClearHistory(); var foo = new Foo(); EventAggregator.SentMessage(foo); EventAggregator.Messaging.WaitForMessage <AllMessagesComplete>(() => runner.SendRemotely(foo)) .ShouldNotBeNull(); } }
public void simplest_usage() { // SAMPLE: simple-remote-service-runner var runner = new RemoteServiceRunner(x => { x.ServiceDirectory = @"c:\code\other-service\src\other-service"; x.Setup.ShadowCopyFiles = true.ToString(); }); // stop and restart the remote AppDomain runner.Recycle(); // There is support for event aggregation between // AppDomain's for coordination runner.SendRemotely(new SomeMessage()); // Shut down and close the remote AppDomain runner.Dispose(); // ENDSAMPLE }
public void copy_assembly_once_by_default() { using (var runner = new RemoteServiceRunner(x => { x.UseParallelServiceDirectory("ApplicationLoaderService"); x.RequireAssemblyContainingType <SampleService.SampleService>(); })) { var path = ".".ToFullPath(); var sampleServiceDll = path.AppendPath("bin/Debug/SampleService.dll"); File.SetLastWriteTime(sampleServiceDll, new DateTime(2014, 01, 01)); var originalWriteTime = File.GetLastWriteTime(sampleServiceDll); runner.Recycle(); var newWriteTime = File.GetLastWriteTime(sampleServiceDll); newWriteTime.ShouldBe(originalWriteTime); } }
public void copy_assembly_once_by_default() { using (var runner = new RemoteServiceRunner(x => { x.UseParallelServiceDirectory("ApplicationLoaderService"); x.RequireAssemblyContainingType<SampleService.SampleService>(); })) { var path = ".".ToFullPath(); var sampleServiceDll = path.AppendPath("bin/Debug/SampleService.dll"); File.SetLastWriteTime(sampleServiceDll, new DateTime(2014, 01, 01)); var originalWriteTime = File.GetLastWriteTime(sampleServiceDll); runner.Recycle(); var newWriteTime = File.GetLastWriteTime(sampleServiceDll); newWriteTime.ShouldBe(originalWriteTime); } }
public void copy_new_remote_assembly_over_old_assembly_when_copymode_always() { using (var runner = new RemoteServiceRunner(x => { x.AssemblyCopyMode = AssemblyCopyMode.Always; x.UseParallelServiceDirectory("ApplicationLoaderService"); x.RequireAssemblyContainingType <SampleService.SampleService>(); })) { var path = ".".ToFullPath(); var sampleServiceDll = path.AppendPath("bin/Debug/SampleService.dll"); File.SetLastWriteTime(sampleServiceDll, new DateTime(2014, 01, 01)); var originalWriteTime = File.GetLastWriteTime(sampleServiceDll); runner.Recycle(); var newWriteTime = File.GetLastWriteTime(sampleServiceDll); newWriteTime.ShouldBeGreaterThan(originalWriteTime); originalWriteTime.ShouldNotBe(newWriteTime); } }
public Task Start() { return Task.Factory.StartNew(() => { try { _runner = new RemoteServiceRunner(x => { x.Setup.ApplicationName = Path.GetDirectoryName(_serviceDirectory).Replace(" ", "-"); x.ServiceDirectory = _serviceDirectory; if (_link.ConfigFile.IsNotEmpty()) x.Setup.ConfigurationFile = _link.ConfigFile; if (_link.BootstrapperName.IsNotEmpty()) x.BootstrapperName = _link.BootstrapperName; x.Setup.ShadowCopyFiles = true.ToString(); }); Console.WriteLine("Successfully started the remote service at " + _serviceDirectory); } catch (Exception e) { Console.WriteLine(e); throw; } _watcher.WatchBinariesAt(_serviceDirectory); }); }
public void loading_a_custom_application_loader() { // SAMPLE: bootstrap-custom-loader var runner = RemoteServiceRunner.For<IApplicationLoader>(x => { // more AppDomain configuration }); // -- or -- runner = new RemoteServiceRunner(x => { // Can be the assembly qualified name of either: // 1. An IApplicationLoader class // 2. An IApplicationSource<,> class // 3. An IBootstrapper class x.BootstrapperName = "MyLib.AppLoader, MyLib"; }); // ENDSAMPLE }
public void start_with_only_the_folder_name_with_an_IApplicationLoader() { var servicePath = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory().AppendPath("ApplicationLoaderService"); using (var runner = new RemoteServiceRunner(servicePath)) { runner.WaitForMessage<LoaderStarted>().LoaderTypeName.ShouldContain("MyApplicationLoader"); } }
public void start_with_only_the_folder_name_with_an_IActivator() { var servicePath = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory().AppendPath("SampleService"); using (var runner = new RemoteServiceRunner(servicePath)) { runner.WaitForServiceToStart<SampleService.SampleService>(); runner.Started.Any().ShouldBeTrue(); } }
public void start_with_a_parallel_folder() { using (var runner = new RemoteServiceRunner(x => { x.UseParallelServiceDirectory("ApplicationLoaderService"); })) { runner.WaitForMessage<LoaderStarted>().LoaderTypeName.ShouldContain("MyApplicationLoader"); } }
public void copy_new_remote_assembly_over_old_assembly_when_copymode_always() { using (var runner = new RemoteServiceRunner(x => { x.AssemblyCopyMode = AssemblyCopyMode.Always; x.UseParallelServiceDirectory("ApplicationLoaderService"); x.RequireAssemblyContainingType<SampleService.SampleService>(); })) { var path = ".".ToFullPath(); var sampleServiceDll = path.AppendPath("bin/Debug/SampleService.dll"); File.SetLastWriteTime(sampleServiceDll, new DateTime(2014, 01, 01)); var originalWriteTime = File.GetLastWriteTime(sampleServiceDll); runner.Recycle(); var newWriteTime = File.GetLastWriteTime(sampleServiceDll); newWriteTime.ShouldBeGreaterThan(originalWriteTime); originalWriteTime.ShouldNotBe(newWriteTime); } }
public void load_assemblies() { // SAMPLE: require-assemblies var runner = new RemoteServiceRunner(x => { // This line of code will copy the Bottles.dll assembly // into the remote AppDomain location x.RequireAssemblyContainingType<Bottles.IPackageFacility>(); x.RequireAssembly("MyAssembly"); }); // ENDSAMPLE }