From 817b6526501beda60891c3037c28deff28998c7c Mon Sep 17 00:00:00 2001 From: Artem Los Date: Thu, 9 Mar 2023 14:55:45 +0100 Subject: [PATCH] Allow overload of the port from config file --- LicenseServer/Config.cs | 2 ++ LicenseServer/Program.cs | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/LicenseServer/Config.cs b/LicenseServer/Config.cs index 25cf0f9..6c4a90d 100644 --- a/LicenseServer/Config.cs +++ b/LicenseServer/Config.cs @@ -48,6 +48,8 @@ public class LicenseServerConfiguration public string PathToCacheFolder { get; set; } [Key(9)] public string WebAPILogAccessToken { get; set; } + [Key(10)] + public string PathToConfigFile { get; set; } } diff --git a/LicenseServer/Program.cs b/LicenseServer/Program.cs index 97fcfba..b2c1665 100644 --- a/LicenseServer/Program.cs +++ b/LicenseServer/Program.cs @@ -29,7 +29,7 @@ namespace LicenseServer { class Program { - public const string versionInfo = "v2.11 (2023-03-02)" ; + public const string versionInfo = "v2.11 (2023-03-09)" ; public const string ServiceName = "license-server"; @@ -134,6 +134,22 @@ public static void Initialization(string[] args, bool runAsService = false) } ConfigurationExpires = config.ValidUntil; + + if (!string.IsNullOrWhiteSpace(config.PathToConfigFile)) + { + try + { + var configData = Newtonsoft.Json.JsonConvert.DeserializeObject(System.IO.File.ReadAllText(config.PathToConfigFile)); + + port = configData.Port; + WriteMessage($"Port changed to {port}"); + + } + catch (Exception ex) + { + WriteMessage($"Config file {config.PathToConfigFile} could not be read. Detailed error message {ex.Message}"); + } + } } else {