Exemplo n.º 1
0
        public static Unit StopSystem(SystemName system)
        {
            lock (sync)
            {
                if (context == system)
                {
                    context = default(SystemName);
                }

                if (defaultSystem == system)
                {
                    defaultSystem = default(SystemName);
                }

                ActorSystem asystem = null;
                var         token   = new ShutdownCancellationToken(system);
                try
                {
                    Process.OnPreShutdown(token);
                }
                finally
                {
                    if (!token.Cancelled)
                    {
                        try
                        {
                            systems.TryGetValue(system, out asystem);
                            if (asystem != null)
                            {
                                asystem.Dispose();
                            }
                        }
                        finally
                        {
                            systems.TryRemove(system, out asystem);
                            Process.OnShutdown(system);
                        }
                    }
                }
                return(unit);
            }
        }
Exemplo n.º 2
0
        public static Unit StartSystem(SystemName system, Option <ICluster> cluster, AppProfile appProfile, ProcessSystemConfig config)
        {
            lock (sync)
            {
                if (systems.ContainsKey(system))
                {
                    throw new InvalidOperationException($"Process-system ({system}) already started");
                }

                var asystem = new ActorSystem(system, cluster, appProfile, config);
                systems.AddOrUpdate(system, asystem, (_, __) => asystem);
                try
                {
                    asystem.Initialise();

                    // Set the default system if the 'default: yes' setting is in the ProcessSystemConfig
                    defaultSystem = defaultSystem.IsValid
                        ? (from c in config.Cluster
                           where c.Default
                           select system)
                                    .IfNone(defaultSystem)
                        : system;
                }
                catch
                {
                    systems.TryRemove(system, out asystem);
                    try
                    {
                        asystem.Dispose();
                    }
                    catch { }
                    throw;
                }
                return(unit);
            }
        }
Exemplo n.º 3
0
        public static Unit StartSystem(SystemName system, Option<ICluster> cluster, AppProfile appProfile, ProcessSystemConfig config)
        {
            lock (sync)
            {
                if (systems.ContainsKey(system))
                {
                    throw new InvalidOperationException($"Process-system ({system}) already started");
                }

                var asystem = new ActorSystem(system, cluster, appProfile, config);
                systems.AddOrUpdate(system, asystem, (_, __) => asystem);
                try
                {
                    asystem.Initialise();

                    // Set the default system if the 'default: yes' setting is in the ProcessSystemConfig
                    defaultSystem = defaultSystem.IsValid
                        ? (from c in config.Cluster
                           where c.Default
                           select system)
                          .IfNone(defaultSystem)
                        : system;
                }
                catch
                {
                    systems.TryRemove(system, out asystem);
                    try
                    {
                        asystem.Dispose();
                    }
                    catch { }
                    throw;
                }
                return unit;
            }
        }