feat: Allow WebAPI to load if no config file is present

This commit is contained in:
Neil Dorin 2026-05-07 10:44:54 -06:00
parent 89c23f5432
commit c52d585a0c
2 changed files with 18 additions and 7 deletions

View file

@ -20,6 +20,8 @@ namespace PepperDash.Essentials.Core.Web
private readonly WebApiServer _debugServer; private readonly WebApiServer _debugServer;
///<example> ///<example>
/// http(s)://{ipaddress}/cws/{basePath} /// http(s)://{ipaddress}/cws/{basePath}
/// http(s)://{ipaddress}/VirtualControl/Rooms/{roomId}/cws/{basePath} /// http(s)://{ipaddress}/VirtualControl/Rooms/{roomId}/cws/{basePath}
@ -301,7 +303,11 @@ namespace PepperDash.Essentials.Core.Web
{ {
Debug.LogMessage(LogEventLevel.Information, this, "{routeName:l}: {routePath:l}/{routeUrl:l}", route.Name, path, route.Url); Debug.LogMessage(LogEventLevel.Information, this, "{routeName:l}: {routePath:l}/{routeUrl:l}", route.Name, path, route.Url);
} }
Debug.LogInformation(this, "Web API initialized and ready to accept requests");
Debug.LogMessage(LogEventLevel.Information, this, new string('-', 50)); Debug.LogMessage(LogEventLevel.Information, this, new string('-', 50));
Debug.LogMessage(LogEventLevel.Information, this, "Developer Tools Web App available at: https://{currentIp}/cws/debug", currentIp);
} }
} }
} }

View file

@ -274,10 +274,9 @@ namespace PepperDash.Essentials
PluginLoader.LoadPlugins(); PluginLoader.LoadPlugins();
Debug.LogMessage(LogEventLevel.Information, "Folder structure verified. Loading config..."); Debug.LogMessage(LogEventLevel.Information, "Folder structure verified. Loading config...");
if (!ConfigReader.LoadConfig2()) if (!ConfigReader.LoadConfig2() || ConfigReader.ConfigObject == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "Essentials Load complete with errors"); Debug.LogMessage(LogEventLevel.Warning, "Unable to load config file. Please ensure a valid config file is present and restart the program.");
return;
} }
Load(); Load();
@ -399,6 +398,12 @@ namespace PepperDash.Essentials
new Core.Monitoring.SystemMonitorController("systemMonitor")); new Core.Monitoring.SystemMonitorController("systemMonitor"));
} }
if (ConfigReader.ConfigObject is null)
{
Debug.LogMessage(LogEventLevel.Warning, "LoadDevices: ConfigObject is null. Cannot load devices.");
return;
}
foreach (var devConf in ConfigReader.ConfigObject.Devices) foreach (var devConf in ConfigReader.ConfigObject.Devices)
{ {
IKeyed newDev = null; IKeyed newDev = null;
@ -452,7 +457,7 @@ namespace PepperDash.Essentials
var tlc = TieLineCollection.Default; var tlc = TieLineCollection.Default;
if (ConfigReader.ConfigObject.TieLines == null) if (ConfigReader.ConfigObject?.TieLines == null)
{ {
return; return;
} }
@ -749,7 +754,7 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
public void LoadRooms() public void LoadRooms()
{ {
if (ConfigReader.ConfigObject.Rooms == null) if (ConfigReader.ConfigObject?.Rooms == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "Notice: Configuration contains no rooms - Is this intentional? This may be a valid configuration."); Debug.LogMessage(LogEventLevel.Information, "Notice: Configuration contains no rooms - Is this intentional? This may be a valid configuration.");
return; return;
@ -786,13 +791,13 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
void LoadLogoServer() void LoadLogoServer()
{ {
if (ConfigReader.ConfigObject.Rooms == null) if (ConfigReader.ConfigObject?.Rooms == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "No rooms configured. Bypassing Logo server startup."); Debug.LogMessage(LogEventLevel.Information, "No rooms configured. Bypassing Logo server startup.");
return; return;
} }
if ( if (ConfigReader.ConfigObject?.Rooms == null ||
!ConfigReader.ConfigObject.Rooms.Any( !ConfigReader.ConfigObject.Rooms.Any(
CheckRoomConfig)) CheckRoomConfig))
{ {