move nlog config to instance and move default to resources
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using NLog;
|
||||||
|
using NLog.Config;
|
||||||
using NLog.Targets;
|
using NLog.Targets;
|
||||||
using Torch.Utils;
|
using Torch.Utils;
|
||||||
|
|
||||||
@@ -12,7 +14,6 @@ namespace Torch.Server
|
|||||||
{
|
{
|
||||||
var isService = Environment.GetEnvironmentVariable("TORCH_SERVICE")
|
var isService = Environment.GetEnvironmentVariable("TORCH_SERVICE")
|
||||||
?.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase) ?? false;
|
?.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase) ?? false;
|
||||||
Target.Register<LogViewerTarget>(nameof(LogViewerTarget));
|
|
||||||
//Ensures that all the files are downloaded in the Torch directory.
|
//Ensures that all the files are downloaded in the Torch directory.
|
||||||
var workingDir = AppContext.BaseDirectory;
|
var workingDir = AppContext.BaseDirectory;
|
||||||
var binDir = Path.Combine(Environment.GetEnvironmentVariable("TORCH_GAME_PATH") ?? workingDir, "DedicatedServer64");
|
var binDir = Path.Combine(Environment.GetEnvironmentVariable("TORCH_GAME_PATH") ?? workingDir, "DedicatedServer64");
|
||||||
@@ -47,12 +48,24 @@ namespace Torch.Server
|
|||||||
instancePath = Directory.CreateDirectory(instanceName).FullName;
|
instancePath = Directory.CreateDirectory(instanceName).FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldNlog = Path.Combine(workingDir, "NLog.config");
|
||||||
|
var newNlog = Path.Combine(instancePath, "NLog.config");
|
||||||
|
if (File.Exists(oldNlog))
|
||||||
|
File.Move(oldNlog, newNlog, true);
|
||||||
|
else if (!File.Exists(newNlog))
|
||||||
|
using (var f = File.Create(newNlog))
|
||||||
|
typeof(Program).Assembly.GetManifestResourceStream("Torch.Server.NLog.config")!.CopyTo(f);
|
||||||
|
|
||||||
var oldTorchCfg = Path.Combine(workingDir, "Torch.cfg");
|
var oldTorchCfg = Path.Combine(workingDir, "Torch.cfg");
|
||||||
var torchCfg = Path.Combine(instancePath, "Torch.cfg");
|
var torchCfg = Path.Combine(instancePath, "Torch.cfg");
|
||||||
|
|
||||||
if (File.Exists(oldTorchCfg))
|
if (File.Exists(oldTorchCfg))
|
||||||
File.Move(oldTorchCfg, torchCfg, true);
|
File.Move(oldTorchCfg, torchCfg, true);
|
||||||
|
|
||||||
|
Target.Register<LogViewerTarget>(nameof(LogViewerTarget));
|
||||||
|
LogManager.Configuration = new XmlLoggingConfiguration(newNlog);
|
||||||
|
LogManager.ReconfigExistingLoggers();
|
||||||
|
|
||||||
var config = Persistent<TorchConfig>.Load(torchCfg);
|
var config = Persistent<TorchConfig>.Load(torchCfg);
|
||||||
config.Data.InstanceName = instanceName;
|
config.Data.InstanceName = instanceName;
|
||||||
config.Data.InstancePath = instancePath;
|
config.Data.InstancePath = instancePath;
|
||||||
|
@@ -160,6 +160,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Remove="Views\WorldSelectControl.xaml" />
|
<Page Remove="Views\WorldSelectControl.xaml" />
|
||||||
<None Include="..\NLog.config" Visible="false" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="Always" />
|
<EmbeddedResource Include="..\NLog.config" Visible="false" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Reference in New Issue
Block a user