public static void OnContainerHealthFaulted(object sender, ContainerHealthMonitorEventArgs args)
        {
            var oldRoleInstance = args.RoleInstance;

            RoleEnvironment.SafeRemove(oldRoleInstance);

            Console.WriteLine($"{oldRoleInstance.Port}: Container faulted. Recovering...");

            RecoverFromFailureAsync(oldRoleInstance, ProcessManager.SingletonInstance).GetAwaiter().GetResult();
        }
Ejemplo n.º 2
0
        private void SafelyCloseProcess(ContainerProcess containerProcess)
        {
            var processToClose = containerProcess.Process;

            if (!processToClose.HasExited && !processToClose.CloseMainWindow())
            {
                processToClose.Kill();
            }
            else
            {
                processToClose.Close();
            }

            if (this.containerProcessDictByPort.TryRemove(containerProcess.Port, out var container))
            {
                Debug.WriteLine($"{typeof(ProcessManager).Name}: removed container[{container.Port}] ({DateTime.Now})");

                if (container.RoleInstance != null)
                {
                    RoleEnvironment.SafeRemove(container.RoleInstance);
                }
            }
        }