private void StartInstance(string assemblyName)
        {
            int    instancesCount  = RoleEnvironment.Roles[assemblyName].Instances.Count;
            string sourceDllPath   = Path.GetFullPath(Path.Combine(this.config.PackageFullFolderPath, assemblyName + ".dll"));
            string destinationPath = Path.GetFullPath(Path.Combine(this.config.PackageTempFullFolderPath, $"{assemblyName}_{instancesCount + 1}"));

            var packageController = new PackageController();

            packageController.CopyFile(sourceDllPath, destinationPath);

            RoleInstance newInstance;

            lock (this.processManager)
            {
                newInstance = new RoleInstance()
                {
                    RoleName         = assemblyName,
                    AssemblyFullPath = destinationPath,
                    Port             = this.processManager.GetAllFreeContainerPorts().First()
                };
                this.processManager.TakeContainer(newInstance);
            }
            ContainerController
            .SendLoadSignalToContainerAsync(newInstance, numberOfAttempts: 1, millisecondsDelay: 0)
            .Wait();
        }
Ejemplo n.º 2
0
        public static void OnValidPackageFound(object sender, ValidPackageFoundEventArgs eventArgs)
        {
            var package = eventArgs.Package;

            var destinationAssemblies = CopyAssemblies(package, package.NumberOfInstances ?? 0);

            CopyDependencies(package);
            ContainerController.SendLoadSignalToContainersAsync(destinationAssemblies).GetAwaiter().GetResult();
        }
        private static Task AttempToSendLoadSignalAsync(RoleInstance newRoleInstance, ProcessManager processManager)
        {
            var task = Task.CompletedTask;

            if (!string.IsNullOrWhiteSpace(newRoleInstance.AssemblyFullPath) && !string.IsNullOrWhiteSpace(newRoleInstance.RoleName))
            {
                Console.WriteLine($"[{newRoleInstance.Port}]: Attempting to send load assembly signal...");
                processManager.TakeContainer(newRoleInstance);
                task = ContainerController.SendLoadSignalToContainerAsync(newRoleInstance, numberOfAttempts: 1);
            }

            return(task);
        }