Skip to content

Commit

Permalink
More Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchitmehta committed Aug 5, 2020
1 parent 3d3bc64 commit 6b3d31f
Show file tree
Hide file tree
Showing 28 changed files with 559 additions and 115 deletions.
4 changes: 2 additions & 2 deletions Kudu.Services.Web/Kudu.Services.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="Pages\DebugConsole2\LinuxConsole2.cshtml">
<Content Update="Pages\OldBash\LinuxBashConsole.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="Pages\DebugConsole2\WindowsConsole2.cshtml">
<Content Update="Pages\OldBash\WindowsBashConsole.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
Expand Down
2 changes: 1 addition & 1 deletion Kudu.Services.Web/KuduWebUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ internal static void MigrateToNetCorePatch(IEnvironment environment)
// Dynamic Install should just contain dotnet
if (fileText.Contains("benv") && fileText.Contains("dotnet") && isRunningOnAzure)
{
FileSystemHelpers.WriteAllText(gitPostReceiveHookFile, fileText.Replace("benv dotnet=2.2", ""));
FileSystemHelpers.WriteAllText(gitPostReceiveHookFile, fileText.Replace("benv dotnet=2.2 dotnet", ""));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Kudu.Services.Web/Pages/DebugConsole/LinuxConsole.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
ViewData["Title"] = "Diagnostic Console";
Layout = "~/Pages/_Layout.cshtml";
Layout = "~/Pages/_Layout.Legacy.cshtml";
}

<head>
Expand Down
2 changes: 1 addition & 1 deletion Kudu.Services.Web/Pages/DebugConsole/WindowsConsole.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
ViewData["Title"] = "Diagnostic Console";
Layout = "~/Pages/_Layout.cshtml";
Layout = "~/Pages/_Layout.Legacy.cshtml";
}

<head>
Expand Down
27 changes: 0 additions & 27 deletions Kudu.Services.Web/Pages/DebugConsole2/DebugConsole2Controller.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Kudu.Services.Web/Pages/Error.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}

<h1 class="text-danger">
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>Error.
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>&nbsp;Error.
</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

Expand Down
21 changes: 5 additions & 16 deletions Kudu.Services.Web/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,15 @@
@if (Kudu.Core.Environment.IsAzureEnvironment())
{
<script>
$.currInst = "@System.Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID")";
$.currInst = "@System.Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID")";
</script>
<script type="text/javascript" src="/Content/Scripts/NavigateToInstance.js"></script>
<script type="text/javascript" src="~/Content/Scripts/NavigateToInstance.js"></script>
}

@if (Kudu.Core.Environment.IsAzureEnvironment())
{
<script type="text/javascript" src="/Content/Scripts/NavigateToInstance.js"></script>
}

@{
var workerIdHash = System.Environment.GetEnvironmentVariable(Constants.AzureWebsiteInstanceId);
var workerIdShortHash = workerIdHash?.Substring(0, 12);
var workerIdShortHash = workerIdHash?.Substring(0, 8);
const string version = "Preview";
var showLearningBanner = !deploymentManager.GetResults().Any();
var welcomeBannerDisplayVal = showLearningBanner ? "display:block" : "display:none";
Expand All @@ -65,7 +61,7 @@
<small>Site UpTime: <i class="fas fa-circle" style="color: #26C281; font-size: x-small; margin-right: 5px"></i>@Tracing.TraceMiddleware.UpTime.ToString(@"dd\.hh\:mm\:ss") | Site Folder: @PathResolver.ResolveRootPath() | Temp Folder: @System.IO.Path.GetTempPath()</small>
<br> <small onclick="clickLink(this)" id="curr-instance" title="@workerIdHash">
Kudu Attached to Instance: &nbsp;<i class="fas fa-desktop fa-style"></i>&nbsp;<a href="#">@workerIdShortHash </a>| <span class="dropdown">
<button class="btn btn-sm dropdown-toggle" type="button" style="background-color: rgb(244, 245, 247);border: none" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button class="btn btn-sm dropdown-toggle" type="button" style="background-color: rgb(244, 245, 247);border: none" id="instanceDropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-network-wired fa-style text-sm"></i> <a href="#"> Switch Instance</a>
</button>
<ul class="dropdown-menu instances_tab_options_cls" id='instances_tab_options'></ul>
Expand Down Expand Up @@ -150,7 +146,7 @@
<a href="/jsonviewer?view_url=/api/settings">App Settings</a>
</li>
<li>
<a href="/wwwroot">Browse WWWRoot</a>
<a href="/sitedir">Browse WWWRoot</a>
</li>
<li>
<a href="/jsonviewer?view_url=/diagnostics/runtime">System Configuration</a>
Expand Down Expand Up @@ -226,8 +222,6 @@
url: "/api/isdeploying?trace=false",
type: "GET",
success: function (data) {
console.log("deployment going on" + data["value"]);
$('#lock_msg').text(data["msg"]);
if (data["value"] == 'True') {
$("#appsvc-welcome-banner").css("display", "none");
Expand All @@ -238,8 +232,6 @@
url: "/api/deployments/latest?trace=false",
type: "GET",
success: function (data) {
console.log("latest deployment data");
console.log(data);
wasDeploying = true;
$("#deployment-status").html(data["status_text"] + "...");
},
Expand All @@ -248,7 +240,6 @@
});
} else {
$('#is-deploying-banner').css("display", "none");
console.log("Trying to show just deployed banner : wasDeploying value is " + wasDeploying);
if (wasDeploying) {
UpdateLatestDeploymentStatus();
}
Expand All @@ -261,15 +252,13 @@
}
function UpdateLatestDeploymentStatus() {
console.log("Making latest API call " + wasDeploying);
$.ajax({
url: "/api/deployments/latest?trace=false",
type: "GET",
success: function (data) {
if (!data["status"]) {
return;
}
console.log(wasDeploying);
$("#appsvc-welcome-banner").css("display", "none");
$("#just-deployed-banner").css("display", "none");
$("#diagnose-btn").css("display", "none");
Expand Down
124 changes: 124 additions & 0 deletions Kudu.Services.Web/Pages/LegacyUI/Env.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
@page
@using System
@using System.Collections
@using System.Collections.Generic
@model Kudu.Services.Web.Pages.EnvLegacyModel
@inject IHttpContextAccessor httpContextAccessor
@inject IDeploymentSettingsManager _settingsManager
@{
ViewData["Title"] = "Environment";
}

<div class="container">
<h3>Index</h3>
<ul>
<li><a href="#sysInfo">System Info</a></li>
<li><a href="#appSettings">App Settings</a></li>
<li><a href="#connectionStrings">Connection Strings</a></li>
<li><a href="#envVariables">Environment variables</a></li>
<li><a href="#path">PATH</a></li>
<li><a href="#httpHeaders">HTTP Headers</a></li>
</ul>
</div>


<div class="container">
<h3 id="sysInfo">System info</h3>
<ul>
<li>System up time: @TimeSpan.FromMilliseconds(Environment.TickCount)</li>
<li>OS version: @Environment.OSVersion</li>
<li>64 bit system: @Environment.Is64BitOperatingSystem</li>
<li>64 bit process: @Environment.Is64BitProcess</li>
<li>Processor count: @Environment.ProcessorCount</li>
<li>Machine name: @Environment.MachineName</li>
<li>Instance id: @Kudu.Core.Infrastructure.InstanceIdUtility.GetInstanceId()</li>
<li>Short instance id: @Kudu.Core.Infrastructure.InstanceIdUtility.GetShortInstanceId()</li>
<li>CLR version: @Environment.Version</li>
<li>System directory: @Environment.SystemDirectory</li>
<li>Current working directory: @Environment.CurrentDirectory</li>
<li>IIS command line: @Environment.CommandLine</li>
@if (Kudu.Core.Helpers.OSDetector.IsOnWindows())
{
var homePath = Environment.GetEnvironmentVariable("HOME");
var localPath = "d:\\local";
<li>@homePath usage: @Html.Raw(Kudu.Core.Environment.GetFreeSpaceHtml(homePath))</li>
if (Kudu.Core.Environment.IsAzureEnvironment() && System.IO.Directory.Exists(localPath))
{
<li>@localPath usage: @Html.Raw(@Kudu.Core.Environment.GetFreeSpaceHtml(localPath))</li>
}
}
</ul>

<h3 id="appSettings">AppSettings</h3>
<ul class="fixed-width">
@using System.Configuration;
@using System.Linq
@using Core.Infrastructure
@using Kudu.Contracts.Settings
@using Microsoft.AspNetCore.Http
@foreach (string name in System.Configuration.ConfigurationManager.AppSettings)
{
<li>
@name = @System.Configuration.ConfigurationManager.AppSettings[name]
</li>
}

@foreach (KeyValuePair<string, string> kv in _settingsManager.GetValues())
{

if (kv.Value != null)
{
<li>@kv.Key = @kv.Value</li>
}

}
</ul>

<h3 id="connectionStrings">Connection Strings</h3>
<ul>
@foreach (ConnectionStringSettings settings in ConfigurationManager.ConnectionStrings)
{
<li>
<span class="fixed-width">@settings.Name</span>
<ul class="fixed-width">
<li>ConnectionString = @settings.ConnectionString</li>
<li>ProviderName = @settings.ProviderName</li>
</ul>
</li>
}
</ul>

<h3 id="envVariables">Environment variables</h3>
<ul class="fixed-width">
@foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables().OfType<DictionaryEntry>().OrderBy(e => e.Key))
{
<li>@entry.Key = @entry.Value</li>
}
</ul>

<h3 id="path">PATH</h3>
<ul class="fixed-width">
@foreach (string folder in Environment.GetEnvironmentVariable("PATH").Split(System.IO.Path.PathSeparator).Where(s => !String.IsNullOrWhiteSpace(s)))
{
<li>@folder</li>
}
</ul>

<h3 id="httpHeaders">HTTP headers</h3>
<ul class="fixed-width">
@foreach (string name in httpContextAccessor.HttpContext.Request.Headers.Keys.OrderBy(s => s))
{
<li>@name=@httpContextAccessor.HttpContext.Request.Headers[name].ToString()</li>
}
</ul>

@*
<h3 id="serverVar">Server variables</h3>
<ul class="fixed-width">
@foreach (string name in HttpContext.Connection.OfType<string>().OrderBy(s => s))
{
<li>@name=@HttpContext.Connection[name]</li>
}
</ul>
*@
</div>
17 changes: 17 additions & 0 deletions Kudu.Services.Web/Pages/LegacyUI/Env.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Kudu.Services.Web.Pages
{
public class EnvLegacyModel : PageModel
{
public void OnGet()
{

}
}
}
23 changes: 23 additions & 0 deletions Kudu.Services.Web/Pages/LegacyUI/Error.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@page
@model ErrorLegacyModel
@{
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
</p>
21 changes: 21 additions & 0 deletions Kudu.Services.Web/Pages/LegacyUI/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Kudu.Services.Web.Pages
{
public class ErrorLegacyModel : PageModel
{
public string RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}
Loading

0 comments on commit 6b3d31f

Please sign in to comment.