Browse Source

Sketch enabling debugging and pushing metadata to clients.

philliphoff-multiplatform
Phillip Hoff 5 years ago
parent
commit
765575313d
  1. 8
      src/Microsoft.Tye.Core/ApplicationFactory.cs
  2. 3
      src/Microsoft.Tye.Core/BindingBuilder.cs
  3. 2
      src/Microsoft.Tye.Core/NodeServiceBuilder.cs
  4. 17
      src/Microsoft.Tye.Hosting/Model/NodeRunInfo.cs
  5. 3
      src/Microsoft.Tye.Hosting/Model/V1/V1RunInfoType.cs
  6. 10
      src/Microsoft.Tye.Hosting/ProcessRunner.cs
  7. 6
      src/Microsoft.Tye.Hosting/TyeDashboardApi.cs
  8. 5
      src/tye/ApplicationBuilderExtensions.cs

8
src/Microsoft.Tye.Core/ApplicationFactory.cs

@ -343,11 +343,17 @@ namespace Microsoft.Tye
var node = new NodeServiceBuilder(configService.Name, packagePath, ServiceSource.Configuration)
{
EnableDebugging = configService.Node.EnableDebugging,
EnableDebugging = !configService.Node.EnableDebugging.HasValue || configService.Node.EnableDebugging.Value,
Replicas = configService.Replicas ?? 1,
Script = configService.Node.Script
};
// If debugging but no explicit binding to the Node.js inspector port has been defined, add one...
if (node.EnableDebugging && !node.Bindings.Any(binding => StringComparer.OrdinalIgnoreCase.Equals(binding.Protocol, "inspector")))
{
node.Bindings.Add(new BindingBuilder { Protocol = "inspector" });
}
service = node;
}
else

3
src/Microsoft.Tye.Core/BindingBuilder.cs

@ -4,7 +4,8 @@
namespace Microsoft.Tye
{
public sealed class BindingBuilder
public sealed class
BindingBuilder
{
public string? Name { get; set; }
public string? ConnectionString { get; set; }

2
src/Microsoft.Tye.Core/NodeServiceBuilder.cs

@ -14,7 +14,7 @@ namespace Microsoft.Tye
PackagePath = packagePath;
}
public bool? EnableDebugging { get; set; }
public bool EnableDebugging { get; set; } = true;
public string PackagePath { get; set; }

17
src/Microsoft.Tye.Hosting/Model/NodeRunInfo.cs

@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Microsoft.Tye.Hosting.Model
{
public class NodeRunInfo : ExecutableRunInfo
{
public NodeRunInfo(string executable, string? workingDirectory, string? args, bool enableDebugging)
: base(executable, workingDirectory, args)
{
EnableDebugging = enableDebugging;
}
public bool EnableDebugging { get; }
}
}

3
src/Microsoft.Tye.Hosting/Model/V1/V1RunInfoType.cs

@ -8,6 +8,7 @@ namespace Microsoft.Tye.Hosting.Model.V1
{
Project,
Executable,
Docker
Docker,
Node
}
}

10
src/Microsoft.Tye.Hosting/ProcessRunner.cs

@ -233,7 +233,8 @@ namespace Microsoft.Tye.Hosting
}
// 3. For non-ASP.NET Core apps, pass the same information in the PORT env variable as a semicolon separated list.
environment["PORT"] = string.Join(";", ports.Select(p => $"{p.Port}"));
var webPorts = ports.Where(port => StringComparer.OrdinalIgnoreCase.Equals(port.Protocol, "http") || StringComparer.OrdinalIgnoreCase.Equals(port.Protocol, "https"));
environment["PORT"] = string.Join(";", webPorts.Select(p => $"{p.Port}"));
if (service.ServiceType == ServiceType.Function)
{
@ -245,6 +246,13 @@ namespace Microsoft.Tye.Hosting
copiedArgs += " --useHttps";
}
}
if (service.Description.RunInfo is NodeRunInfo info && info.EnableDebugging)
{
var binding = ports.First(port => StringComparer.OrdinalIgnoreCase.Equals(port.Protocol, "inspector"));
copiedArgs = $"--inspect={binding.Port} {copiedArgs}";
}
}
var backOff = TimeSpan.FromSeconds(5);

6
src/Microsoft.Tye.Hosting/TyeDashboardApi.cs

@ -167,6 +167,12 @@ namespace Microsoft.Tye.Hosting
v1RunInfo.WorkingDirectory = dockerRunInfo.WorkingDirectory;
v1RunInfo.Args = dockerRunInfo.Args;
break;
case NodeRunInfo nodeRunInfo:
v1RunInfo.Type = V1RunInfoType.Node;
v1RunInfo.Args = nodeRunInfo.Args;
v1RunInfo.Executable = nodeRunInfo.Executable;
v1RunInfo.WorkingDirectory = nodeRunInfo.WorkingDirectory;
break;
case ExecutableRunInfo executableRunInfo:
v1RunInfo.Type = V1RunInfoType.Executable;
v1RunInfo.Args = executableRunInfo.Args;

5
src/tye/ApplicationBuilderExtensions.cs

@ -169,10 +169,9 @@ namespace Microsoft.Tye
var main = mainNode.Value;
string enableDebuggingArg = !node.EnableDebugging.HasValue || node.EnableDebugging.Value ? "--inspect ": "";
string args = $"{enableDebuggingArg}{main}";
string args = $"{main}";
runInfo = new ExecutableRunInfo(executablePath, workingDirectory, args);
runInfo = new NodeRunInfo(executablePath, workingDirectory, args, node.EnableDebugging);
replicas = node.Replicas;
liveness = null;
readiness = null;

Loading…
Cancel
Save