private void CreateNewInstance(string url = null)
        {
            var id             = new BrowserInstanceIdentifier(++instanceIdCounter);
            var isMainInstance = instances.Count == 0;
            var instanceLogger = logger.CloneFor($"BrowserInstance {id}");
            var startUrl       = url ?? settings.StartUrl;
            var instance       = new BrowserApplicationInstance(appConfig, settings, id, isMainInstance, messageBox, instanceLogger, text, uiFactory, startUrl);

            instance.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args);
            instance.PopupRequested += Instance_PopupRequested;
            instance.Terminated     += Instance_Terminated;

            instance.Initialize();
            instances.Add(instance);
            InstanceStarted?.Invoke(instance);

            logger.Info($"Created browser instance {instance.Id}.");
        }
Example #2
0
 private void HandleInstanceStart(Guid applicationId, IProcess process)
 {
     logger.Debug($"Detected start of whitelisted application instance {process}.");
     Task.Run(() => InstanceStarted?.Invoke(applicationId, process));
 }
 public void When(InstanceStarted e)
 {
     _writer.UpdateEnforcingNew(v => v.List.Add(e.CodeVersion));
 }
Example #4
0
        static void Main(string[] args)
        {
            ConfigureObserver();

            var settings = LoadSettings();

            foreach (var setting in settings)
            {
                SystemObserver.Notify("[{0}] = {1}", setting.Key, setting.Value);
            }

            var setup = new SetupClassThatReplacesIoCContainerFramework();

            var integrationPath = settings["DataPath"];

            if (integrationPath.StartsWith("file:"))
            {
                var path   = integrationPath.Remove(0, 5);
                var config = FileStorage.CreateConfig(path);
                setup.Streaming         = config.CreateStreaming();
                setup.Tapes             = config.CreateTape;
                setup.Docs              = config.CreateNuclear(setup.Strategy).Container;
                setup.CreateInbox       = s => config.CreateInbox(s);
                setup.CreateQueueWriter = config.CreateQueueWriter;
            }
            else if (integrationPath.StartsWith("azure:"))
            {
                var path   = integrationPath.Remove(0, 6);
                var config = AzureStorage.CreateConfig(path);
                setup.Streaming         = config.CreateStreaming();
                setup.Tapes             = config.CreateTape;
                setup.Docs              = config.CreateNuclear(setup.Strategy).Container;
                setup.CreateInbox       = s => config.CreateInbox(s);
                setup.CreateQueueWriter = config.CreateQueueWriter;
            }
            else
            {
                throw new InvalidOperationException("Unsupperted environment");
            }
            var components = setup.AssembleComponents();


            var stream = setup.Tapes(Topology.TapesContainer).GetOrCreateStream(Topology.DomainLogName);

            StartupProjectionRebuilder.Rebuild(components.Setup.Docs, stream);
            using (var cts = new CancellationTokenSource())
                using (var engine = components.Builder.Build())
                {
                    var task = engine.Start(cts.Token);

                    var version         = ConfigurationManager.AppSettings.Get("appharbor.commit_id");
                    var instanceStarted = new InstanceStarted(version, "engine", Process.GetCurrentProcess().ProcessName);
                    components.Simple.SendOne(instanceStarted);

                    //startupMessages.ForEach(c => components.Sender.SendCommandsAsBatch(new ISampleCommand[] { c }));

                    Console.WriteLine(@"Press enter to stop");
                    Console.ReadLine();
                    cts.Cancel();
                    if (!task.Wait(5000))
                    {
                        Console.WriteLine(@"Terminating");
                    }
                }
        }
Example #5
0
        static void Main(string[] args)
        {
            ConfigureObserver();

            var settings = LoadSettings();

            foreach (var setting in settings)
            {
                SystemObserver.Notify("[{0}] = {1}", setting.Key, setting.Value);
            }

            var setup = new SetupClassThatReplacesIoCContainerFramework();

            var integrationPath = settings["DataPath"];
            if (integrationPath.StartsWith("file:"))
            {
                var path = integrationPath.Remove(0, 5);
                var config = FileStorage.CreateConfig(path);
                setup.Streaming = config.CreateStreaming();
                setup.Tapes = config.CreateTape;
                setup.Docs = config.CreateNuclear(setup.Strategy).Container;
                setup.CreateInbox = s => config.CreateInbox(s);
                setup.CreateQueueWriter = config.CreateQueueWriter;
            }
            else if (integrationPath.StartsWith("azure:"))
            {
                var path = integrationPath.Remove(0, 6);
                var config = AzureStorage.CreateConfig(path);
                setup.Streaming = config.CreateStreaming();
                setup.Tapes = config.CreateTape;
                setup.Docs = config.CreateNuclear(setup.Strategy).Container;
                setup.CreateInbox = s => config.CreateInbox(s);
                setup.CreateQueueWriter = config.CreateQueueWriter;
            }
            else
            {
                throw new InvalidOperationException("Unsupperted environment");
            }
            var components = setup.AssembleComponents();

            var stream = setup.Tapes(Topology.TapesContainer).GetOrCreateStream(Topology.DomainLogName);

            StartupProjectionRebuilder.Rebuild(components.Setup.Docs, stream);
            using (var cts = new CancellationTokenSource())
            using (var engine = components.Builder.Build())
            {
                var task = engine.Start(cts.Token);

                var version = ConfigurationManager.AppSettings.Get("appharbor.commit_id");
                var instanceStarted = new InstanceStarted(version, "engine", Process.GetCurrentProcess().ProcessName);
                components.Simple.SendOne(instanceStarted);

                //startupMessages.ForEach(c => components.Sender.SendCommandsAsBatch(new ISampleCommand[] { c }));

                Console.WriteLine(@"Press enter to stop");
                Console.ReadLine();
                cts.Cancel();
                if (!task.Wait(5000))
                {
                    Console.WriteLine(@"Terminating");
                }
            }
        }
 public void When(InstanceStarted e)
 {
     _writer.UpdateEnforcingNew(v => v.List.Add(e.CodeVersion));
 }