示例#1
0
        public static void Start(Assembly[] asmList, List <RuntimeConfig> cfgList, Action init, bool isMultiProcess = false)
        {
            Global.Init(asmList);

            init();

            Host c = null;

            if (!isMultiProcess || cfgList == null)
            {
                var    cfg         = Global.Config;
                string localAddrV4 = "";
                if (cfg.InternalIp == "auto")
                {
                    localAddrV4 = Basic.GetLocalIPv4(NetworkInterfaceType.Ethernet);
                }
                c = Host.Create("App", localAddrV4, cfg.ExternalIp, 17777, false);

                foreach (var aName in cfg.DefaultActorNames)
                {
                    c.CreateActor(aName, aName);
                }
            }
            else
            {
                foreach (var cfg in cfgList)
                {
                    string appName = Environment.GetEnvironmentVariable("AppName");
                    if (!isMultiProcess)
                    {
                        foreach (var aName in cfg.DefaultActorNames)
                        {
                            c.CreateActor(aName, aName);
                        }
                    }
                    else
                    {
                        if (appName != cfg.AppName)
                        {
                            continue;
                        }
                        if (c == null)
                        {
                            //if(cfg.InternalIp == "auto")
                            //var localAddrV4 = Basic.GetLocalIPv4(NetworkInterfaceType.Ethernet);
                            c = Host.Create(cfg.AppName, cfg.InternalIp, cfg.ExternalIp, cfg.Port, false);
                        }
                        foreach (var aName in cfg.DefaultActorNames)
                        {
                            c.CreateActor(aName, aName);
                        }
                    }
                }
            }

            HostHelper.RunThread(c);
        }
示例#2
0
文件: Bootstrap.cs 项目: sekkit/Fenix
        public static void StartMultiProcess(Assembly[] asmList, RuntimeConfig cfg, Action init, List <RuntimeConfig> allCfgs)
        {
            Environment.SetEnvironmentVariable("AppName", cfg.AppName);

#if !CLIENT
            Global.SingleProcessMode = false;
            Global.Init(cfg, asmList);

            init();

            string appName = Environment.GetEnvironmentVariable("AppName");

            Host host = Host.Create(cfg.AppName, cfg.InternalIP, cfg.ExternalIP, cfg.Port, false);

            foreach (var aName in cfg.DefaultActorNames)
            {
                host.CreateActorLocally(aName, aName);
            }

            HostHelper.RunThread(host, allCfgs);
#endif
        }