[+] 接入ET8服务端

[+] 接入ET8服务端
This commit is contained in:
ALEXTANG
2023-07-13 12:23:48 +08:00
parent e0be062006
commit 336d4b2eb9
1316 changed files with 130657 additions and 626 deletions

View File

@@ -0,0 +1,26 @@
using System.Collections;
using System.Diagnostics;
namespace ET.Server
{
[EntitySystemOf(typeof(WatcherComponent))]
[FriendOf(typeof(WatcherComponent))]
public static partial class WatcherComponentSystem
{
[EntitySystem]
public static void Awake(this WatcherComponent self)
{
string[] localIP = NetworkHelper.GetAddressIPs();
var processConfigs = StartProcessConfigCategory.Instance.GetAll();
foreach (StartProcessConfig startProcessConfig in processConfigs.Values)
{
if (!WatcherHelper.IsThisMachine(startProcessConfig.InnerIP, localIP))
{
continue;
}
System.Diagnostics.Process process = WatcherHelper.StartProcess(startProcessConfig.Id);
self.Processes.Add(startProcessConfig.Id, process);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 74b099ff0f3523d47af0595ae8bf6b3f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections;
using System.Diagnostics;
namespace ET.Server
{
public static partial class WatcherHelper
{
public static StartMachineConfig GetThisMachineConfig()
{
string[] localIP = NetworkHelper.GetAddressIPs();
StartMachineConfig startMachineConfig = null;
foreach (StartMachineConfig config in StartMachineConfigCategory.Instance.GetAll().Values)
{
if (!WatcherHelper.IsThisMachine(config.InnerIP, localIP))
{
continue;
}
startMachineConfig = config;
break;
}
if (startMachineConfig == null)
{
throw new Exception("not found this machine ip config!");
}
return startMachineConfig;
}
public static bool IsThisMachine(string ip, string[] localIPs)
{
if (ip != "127.0.0.1" && ip != "0.0.0.0" && !((IList) localIPs).Contains(ip))
{
return false;
}
return true;
}
public static System.Diagnostics.Process StartProcess(int processId, int createScenes = 0)
{
StartProcessConfig startProcessConfig = StartProcessConfigCategory.Instance.Get(processId);
const string exe = "dotnet";
string arguments = $"App.dll" +
$" --Process={startProcessConfig.Id}" +
$" --AppType=Server" +
$" --StartConfig={Options.Instance.StartConfig}" +
$" --Develop={Options.Instance.Develop}" +
$" --LogLevel={Options.Instance.LogLevel}" +
$" --Console={Options.Instance.Console}";
Log.Debug($"{exe} {arguments}");
System.Diagnostics.Process process = ProcessHelper.Run(exe, arguments);
return process;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95a7ba0a15340d143a8eb9787899fcc6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: