Skip to content

Commit

Permalink
Fixes local debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
helto4real committed Dec 8, 2020
1 parent 08c9f84 commit 534ff57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ ENV \
HASSCLIENT_MSGLOGLEVEL=Default \
NETDAEMON__SOURCEFOLDER=/data \
NETDAEMON__ADMIN=true \
ASPNETCORE_URLS=http://+:5000
ASPNETCORE_URLS=http://+:5000 \
HASS_DISABLE_LOCAL_ASM=true


ENTRYPOINT ["/init"]
13 changes: 11 additions & 2 deletions src/DaemonRunner/DaemonRunner/NetDaemonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,25 @@ public static IHostBuilder UseNetDaemon(this IHostBuilder hostBuilder)

private static void RegisterNetDaemonAssembly(IServiceCollection services)
{
if (BypassLocalAssemblyLoading())
if (!BypassLocalAssemblyLoading())
services.AddSingleton<IDaemonAppCompiler, LocalDaemonAppCompiler>();
else
services.AddSingleton<IDaemonAppCompiler, DaemonAppCompiler>();
}

/// <summary>
/// Returns true if local loading of assemblies should be preferred.
/// This is typically when running in container. When running in dev
/// you want the local loading
/// </summary>
private static bool BypassLocalAssemblyLoading()
{
var value = Environment.GetEnvironmentVariable("HASS_DISABLE_LOCAL_ASM");
return bool.TryParse(value, out var result) && result;
if (bool.TryParse(value, out var result))
{
return result;
}
return false;
}
}
}

0 comments on commit 534ff57

Please sign in to comment.