mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-07-02 10:38:16 +00:00
fix: improve error logging for routing devices and ports; ensure API server initializes correctly
This commit is contained in:
parent
a45b26fadc
commit
3137796335
3 changed files with 18 additions and 6 deletions
|
|
@ -69,14 +69,14 @@ namespace PepperDash.Essentials.Core.Config
|
||||||
// Get the source device
|
// Get the source device
|
||||||
if (!(DeviceManager.GetDeviceForKey(SourceKey) is IRoutingOutputs sourceDev))
|
if (!(DeviceManager.GetDeviceForKey(SourceKey) is IRoutingOutputs sourceDev))
|
||||||
{
|
{
|
||||||
LogError("Routable source not found");
|
LogError($"Routable source not found for key '{SourceKey}'");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the destination device
|
// Get the destination device
|
||||||
if (!(DeviceManager.GetDeviceForKey(DestinationKey) is IRoutingInputs destDev))
|
if (!(DeviceManager.GetDeviceForKey(DestinationKey) is IRoutingInputs destDev))
|
||||||
{
|
{
|
||||||
LogError("Routable destination not found");
|
LogError($"Routable destination not found for key '{DestinationKey}'");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ namespace PepperDash.Essentials.Core.Config
|
||||||
|
|
||||||
if (sourceOutputPort == null)
|
if (sourceOutputPort == null)
|
||||||
{
|
{
|
||||||
LogError("Source does not contain port");
|
LogError($"Source '{SourceKey}' does not contain port '{SourcePort}'");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,7 +94,7 @@ namespace PepperDash.Essentials.Core.Config
|
||||||
|
|
||||||
if (destinationInputPort == null)
|
if (destinationInputPort == null)
|
||||||
{
|
{
|
||||||
LogError("Destination does not contain port");
|
LogError($"Destination '{DestinationKey}' does not contain port '{DestinationPort}'");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Core.Web
|
||||||
|
|
||||||
private readonly WebApiServer _debugServer;
|
private readonly WebApiServer _debugServer;
|
||||||
|
|
||||||
|
private bool isInitialized;
|
||||||
|
|
||||||
|
|
||||||
///<example>
|
///<example>
|
||||||
|
|
@ -230,6 +230,11 @@ namespace PepperDash.Essentials.Core.Web
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
|
if (isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AddRoute(new HttpCwsRoute("apiPaths")
|
AddRoute(new HttpCwsRoute("apiPaths")
|
||||||
{
|
{
|
||||||
Name = "GetPaths",
|
Name = "GetPaths",
|
||||||
|
|
@ -264,6 +269,8 @@ namespace PepperDash.Essentials.Core.Web
|
||||||
_debugServer.Start();
|
_debugServer.Start();
|
||||||
|
|
||||||
GetPaths();
|
GetPaths();
|
||||||
|
|
||||||
|
isInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,9 @@ namespace PepperDash.Essentials
|
||||||
CrestronConsole.AddNewConsoleCommand(DeviceManager.GetRoutingPorts,
|
CrestronConsole.AddNewConsoleCommand(DeviceManager.GetRoutingPorts,
|
||||||
"getroutingports", "Reports all routing ports, if any. Requires a device key", ConsoleAccessLevelEnum.AccessOperator);
|
"getroutingports", "Reports all routing ports, if any. Requires a device key", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
DeviceManager.AddDevice(new EssentialsWebApi("essentialsWebApi", "Essentials Web API"));
|
|
||||||
|
var apiServer = new EssentialsWebApi("essentialsWebApi", "Essentials Web API");
|
||||||
|
DeviceManager.AddDevice(apiServer);
|
||||||
|
|
||||||
if (!Debug.DoNotLoadConfigOnNextBoot)
|
if (!Debug.DoNotLoadConfigOnNextBoot)
|
||||||
{
|
{
|
||||||
|
|
@ -148,6 +150,9 @@ namespace PepperDash.Essentials
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init the API server even if we're not loading config to allow for dynamic loading via console command
|
||||||
|
apiServer.Initialize();
|
||||||
|
|
||||||
if (!(bool)preventInitialization)
|
if (!(bool)preventInitialization)
|
||||||
{
|
{
|
||||||
SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true;
|
SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue