diff --git a/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/BasicsStation/BasicsStationNetworkServerStartup.cs b/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/BasicsStation/BasicsStationNetworkServerStartup.cs index 5817bdc2eb..ed629d4b64 100644 --- a/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/BasicsStation/BasicsStationNetworkServerStartup.cs +++ b/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/BasicsStation/BasicsStationNetworkServerStartup.cs @@ -129,7 +129,7 @@ public void ConfigureServices(IServiceCollection services) if (NetworkServerConfiguration.ClientCertificateMode is not ClientCertificateMode.NoCertificate) _ = services.AddSingleton(); - _ = NetworkServerConfiguration.RunningAsIoTEdgeModule + _ = NetworkServerConfiguration.RunningAsIoTEdgeModule || NetworkServerConfiguration.IsLocalDevelopment ? services.AddSingleton() : services.AddHostedService() .AddSingleton() diff --git a/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/NetworkServerConfiguration.cs b/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/NetworkServerConfiguration.cs index e2d60c7601..c3789468be 100644 --- a/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/NetworkServerConfiguration.cs +++ b/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/NetworkServerConfiguration.cs @@ -136,10 +136,17 @@ public class NetworkServerConfiguration /// public string RedisConnectionString { get; private set; } + /// /// Specifies the pool size for upstream AMQP connection /// public uint IotHubConnectionPoolSize { get; internal set; } = 1; + /// + /// Specificies wether we are running in local development mode. + /// + public bool IsLocalDevelopment { get; set; } + + /// /// Specifies the Processing Delay in Milliseconds /// @@ -153,9 +160,9 @@ public static NetworkServerConfiguration CreateFromEnvironmentVariables() // Create case insensitive dictionary from environment variables var envVars = new CaseInsensitiveEnvironmentVariables(Environment.GetEnvironmentVariables()); config.ProcessingDelayInMilliseconds = envVars.GetEnvVar("PROCESSING_DELAY_IN_MS", config.ProcessingDelayInMilliseconds); - + config.IsLocalDevelopment = envVars.GetEnvVar("LOCAL_DEVELOPMENT", false); // We disable IoT Edge runtime either when we run in the cloud or during local development. - config.RunningAsIoTEdgeModule = !(envVars.GetEnvVar("CLOUD_DEPLOYMENT", false) || envVars.GetEnvVar("LOCAL_DEVELOPMENT", false)); + config.RunningAsIoTEdgeModule = !(envVars.GetEnvVar("CLOUD_DEPLOYMENT", false) || config.IsLocalDevelopment); var iotHubHostName = envVars.GetEnvVar("IOTEDGE_IOTHUBHOSTNAME", envVars.GetEnvVar("IOTHUBHOSTNAME", string.Empty)); config.IoTHubHostName = !string.IsNullOrEmpty(iotHubHostName) ? iotHubHostName : throw new InvalidOperationException("Either 'IOTEDGE_IOTHUBHOSTNAME' or 'IOTHUBHOSTNAME' environment variable should be populated"); @@ -204,7 +211,7 @@ public static NetworkServerConfiguration CreateFromEnvironmentVariables() : throw new NotSupportedException($"'IOTHUB_CONNECTION_POOL_SIZE' needs to be between 1 and {AmqpConnectionPoolSettings.AbsoluteMaxPoolSize}."); config.RedisConnectionString = envVars.GetEnvVar("REDIS_CONNECTION_STRING", string.Empty); - if (!config.RunningAsIoTEdgeModule && string.IsNullOrEmpty(config.RedisConnectionString)) + if (!config.RunningAsIoTEdgeModule && !config.IsLocalDevelopment && string.IsNullOrEmpty(config.RedisConnectionString)) throw new InvalidOperationException("'REDIS_CONNECTION_STRING' can't be empty if running network server as part of a cloud only deployment."); return config;