Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchitmehta authored Jun 4, 2019
2 parents fe5ca50 + 30942e3 commit 0ebb2cb
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Kudu.Core/Deployment/Generator/OryxBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public override Task Build(DeploymentContext context)
if (args.RunOryxBuild)
{
PreOryxBuild(context);

string buildCommand = args.GenerateOryxBuildCommand(context);
RunCommand(context, buildCommand, false, "Running oryx build...");

Expand Down
2 changes: 1 addition & 1 deletion Kudu.Core/Deployment/Oryx/ExpressBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void SetupExpressBuilderArtifacts(string outputPath)
// For App service express mode
// Generate packagename.txt and packagepath
string packagename = "node_modules.zip:/node_modules";

File.WriteAllText(packageNameFile, packagename);
File.WriteAllText(packagePathFile, outputPath);
}
Expand Down
181 changes: 181 additions & 0 deletions Kudu.Core/Deployment/Oryx/OryxArguments.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
using System;
using System.Collections.Generic;
using System.Text;
using Kudu.Core.Deployment.Oryx;

namespace Kudu.Core.Deployment
{
public class OryxArguments
{
public bool RunOryxBuild { get; set; }

public Framework Language { get; set; }

public string Version { get; set; }

public string PublishFolder { get; set; }

public string VirtualEnv { get; private set; }

public BuildOptimizationsFlags Flags { get; set; }

public OryxArguments()
{
RunOryxBuild = false;

string framework = System.Environment.GetEnvironmentVariable("FRAMEWORK");
string version = System.Environment.GetEnvironmentVariable("FRAMEWORK_VERSION");
string buildFlags = System.Environment.GetEnvironmentVariable("BUILD_FLAGS");

if (string.IsNullOrEmpty(framework) ||
string.IsNullOrEmpty(version))
{
return;
}

Language = SupportedFrameworks.ParseLanguage(framework);
if (Language == Framework.None)
{
return;
}

RunOryxBuild = true;
Version = version;

// Parse Build Flags
Flags = BuildFlagsHelper.Parse(buildFlags);

// Set language specific
SetLanguageOptions();
}

private void SetLanguageOptions()
{
switch(Language)
{
case Framework.None:
return;

case Framework.Python:
SetVirtualEnvironment();
return;

case Framework.DotNETCore:
return;

case Framework.NodeJs:
// For node, enable compress option by default
if (Flags == BuildOptimizationsFlags.None)
{
Flags = BuildOptimizationsFlags.CompressModules;
}

return;
}
}

private void SetVirtualEnvironment()
{
string virtualEnvName = "antenv";
if (Version.StartsWith("3.6"))
{
virtualEnvName = "antenv3.6";
}
else if (Version.StartsWith("2.7"))
{
virtualEnvName = "antenv2.7";
}

VirtualEnv = virtualEnvName;
}

public string GenerateOryxBuildCommand(DeploymentContext context)
{
StringBuilder args = new StringBuilder();

// Input/Output
args.AppendFormat("oryx build {0} -o {1}", context.OutputPath, context.OutputPath);

// Language
switch (Language)
{
case Framework.None:
break;

case Framework.NodeJs:
args.AppendFormat(" -l nodejs");
break;

case Framework.Python:
args.AppendFormat(" -l python");
break;

case Framework.DotNETCore:
args.AppendFormat(" -l dotnet");
break;
}

// Version
args.AppendFormat(" --language-version {0}", Version);

// Build Flags
switch (Flags)
{
case BuildOptimizationsFlags.Off:
case BuildOptimizationsFlags.None:
break;

case BuildOptimizationsFlags.CompressModules:
AddTempDirectoryOption(args, context.BuildTempPath);
if (Language == Framework.NodeJs)
{
AddNodeCompressOption(args, "tar-gz");
}
else if (Language == Framework.Python)
{
AddPythonCompressOption(args);
}

break;

case BuildOptimizationsFlags.UseExpressBuild:
AddTempDirectoryOption(args, context.BuildTempPath);
if (Language == Framework.NodeJs)
{
AddNodeCompressOption(args, "zip");
}

break;
}

// Virtual Env?
if (!String.IsNullOrEmpty(VirtualEnv))
{
args.AppendFormat(" -p virtualenv_name={0}", VirtualEnv);
}

// Publish Output?
if (!String.IsNullOrEmpty(PublishFolder))
{
args.AppendFormat(" -publishedOutputPath {0}", PublishFolder);
}

return args.ToString();
}

private static void AddTempDirectoryOption(StringBuilder args, string tempDir)
{
args.AppendFormat(" -i {0}", tempDir);
}

private static void AddNodeCompressOption(StringBuilder args, string format)
{
args.AppendFormat(" -p compress_node_modules={0}", format);
}

private static void AddPythonCompressOption(StringBuilder args)
{
args.AppendFormat(" -p zip_venv_dir");
}
}
}
3 changes: 2 additions & 1 deletion Kudu.Services/Diagnostics/LogStreamManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class LogStreamManager

private const string volatileLogsPath = "/appsvctmp/volatile/logs/runtime";

private const string volatileLogsPath = "/appsvctmp/volatile/logs/runtime";

// CORE TODO
//private ShutdownDetector _shutdownDetector;
//private CancellationTokenRegistration _cancellationTokenRegistration;
Expand Down Expand Up @@ -99,7 +101,6 @@ public async Task ProcessRequest(HttpContext context)
var firstPath = routePath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();

// Ensure mounted logFiles dir

string mountedLogFilesDir = Path.Combine(_logPath, routePath);

FileSystemHelpers.EnsureDirectory(mountedLogFilesDir);
Expand Down

0 comments on commit 0ebb2cb

Please sign in to comment.