sanity checks @ startup
This commit is contained in:
47
Yavsc/Startup/Startup.SanityChecks.cs
Normal file
47
Yavsc/Startup/Startup.SanityChecks.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using System;
|
||||||
|
using Google.Apis.Auth.OAuth2;
|
||||||
|
using Microsoft.AspNet.Builder;
|
||||||
|
using Microsoft.AspNet.Hosting;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Yavsc
|
||||||
|
{
|
||||||
|
public partial class Startup
|
||||||
|
{
|
||||||
|
public void CheckServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CheckApp(IApplicationBuilder app,
|
||||||
|
SiteSettings siteSettings, IHostingEnvironment env,
|
||||||
|
ILoggerFactory loggerFactory
|
||||||
|
)
|
||||||
|
{
|
||||||
|
var logger = loggerFactory.CreateLogger<Startup>();
|
||||||
|
|
||||||
|
var creds = GoogleSettings?.Account?.private_key;
|
||||||
|
if (creds==null)
|
||||||
|
throw new InvalidOperationException("No Google API credential");
|
||||||
|
var initializer = new ServiceAccountCredential.Initializer(Startup.GoogleSettings.Account.client_email);
|
||||||
|
initializer = initializer.FromPrivateKey(Startup.GoogleSettings.Account.private_key);
|
||||||
|
if (initializer==null)
|
||||||
|
|
||||||
|
throw new InvalidOperationException("Invalid Google API credential");
|
||||||
|
|
||||||
|
foreach (var feature in app.ServerFeatures)
|
||||||
|
{
|
||||||
|
var val = JsonConvert.SerializeObject(feature.Value);
|
||||||
|
logger.LogInformation( $"#Feature _{feature.Key}_: {val}" );
|
||||||
|
}
|
||||||
|
foreach (var prop in app.Properties)
|
||||||
|
{
|
||||||
|
var val = JsonConvert.SerializeObject(prop.Value);
|
||||||
|
logger.LogInformation( $"#Property _{prop.Key}_: {val}" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1226,6 +1226,10 @@
|
|||||||
<Content Include="Views\Manage\SetGoogleCalendar.cshtml" />
|
<Content Include="Views\Manage\SetGoogleCalendar.cshtml" />
|
||||||
<Content Include="Views\Shared\Components\Calendar\Default.cshtml" />
|
<Content Include="Views\Shared\Components\Calendar\Default.cshtml" />
|
||||||
<Content Include="wwwroot\js\site.js" />
|
<Content Include="wwwroot\js\site.js" />
|
||||||
|
<Content Include="GoogleApiSupport\Google.Apis\Util\Store\FileDataStore.cs" />
|
||||||
|
<Content Include="appsettings.Development.json" />
|
||||||
|
<Content Include="Views\BrusherProfile\Edit.cshtml" />
|
||||||
|
<Content Include="Startup\Startup.SanityChecks.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="../YavscLib/YavscLib.csproj" />
|
<Import Project="../YavscLib/YavscLib.csproj" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
Reference in New Issue
Block a user