Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions src/ServiceControl.Audit/Infrastructure/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace ServiceControl.Audit.Infrastructure
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
Expand All @@ -16,6 +17,7 @@ namespace ServiceControl.Audit.Infrastructure
using Autofac;
using Autofac.Core.Activators.Reflection;
using Autofac.Features.ResolveAnything;
using ByteSizeLib;
using Microsoft.Owin.Hosting;
using Monitoring;
using NServiceBus;
Expand Down Expand Up @@ -168,15 +170,48 @@ long DataSize()
}
}

long FolderSize()
{
try
{
var dir = new DirectoryInfo(settings.DbPath);
var dirSize = DirSize(dir);
return dirSize;
}
catch
{
return -1;
}
}

static long DirSize(DirectoryInfo d)
{
long size = 0;
FileInfo[] fis = d.GetFiles();
foreach (FileInfo fi in fis)
{
size += fi.Length;
}
DirectoryInfo[] dis = d.GetDirectories();
foreach (DirectoryInfo di in dis)
{
size += DirSize(di);
}
return size;
}

void RecordStartup(LoggingSettings loggingSettings, EndpointConfiguration endpointConfiguration)
{
var version = FileVersionInfo.GetVersionInfo(typeof(Bootstrapper).Assembly.Location).ProductVersion;
var dataSize = DataSize();
var folderSize = FolderSize();
var startupMessage = $@"
-------------------------------------------------------------
ServiceControl Audit Version: {version}
Audit Retention Period: {settings.AuditRetentionPeriod}
Forwarding Audit Messages: {settings.ForwardAuditMessages}
Database Size: {DataSize()} bytes
Database Size: {ByteSize.FromBytes(dataSize).ToString("#.##", CultureInfo.InvariantCulture)}
Database Folder Size: {ByteSize.FromBytes(folderSize).ToString("#.##", CultureInfo.InvariantCulture)}
ServiceControl Logging Level: {loggingSettings.LoggingLevel}
RavenDB Logging Level: {loggingSettings.RavenDBLogLevel}
Selected Transport Customization: {settings.TransportCustomizationType}
Expand Down Expand Up @@ -235,4 +270,4 @@ public ConstructorInfo[] FindConstructors(Type targetType)
static readonly ConcurrentDictionary<Type, ConstructorInfo[]> Cache = new ConcurrentDictionary<Type, ConstructorInfo[]>();
}
}
}
}
3 changes: 2 additions & 1 deletion src/ServiceControl.Audit/ServiceControl.Audit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ByteSize" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.7" />
<PackageReference Include="Autofac.WebApi2" Version="4.3.1" />
Expand Down Expand Up @@ -56,4 +57,4 @@
</ItemGroup>
</Target>

</Project>
</Project>
44 changes: 39 additions & 5 deletions src/ServiceControl/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Particular.ServiceControl
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
Expand All @@ -14,6 +15,7 @@ namespace Particular.ServiceControl
using Autofac;
using Autofac.Core.Activators.Reflection;
using Autofac.Features.ResolveAnything;
using ByteSizeLib;
using global::ServiceControl.CompositeViews.Messages;
using global::ServiceControl.Infrastructure;
using global::ServiceControl.Infrastructure.DomainEvents;
Expand Down Expand Up @@ -174,26 +176,58 @@ long DataSize()
try
{
var info = new FileInfo(datafilePath);

return info.Length;
}
catch (Exception)
catch
{
return -1;
}
}

long FolderSize()
{
try
{
var dir = new DirectoryInfo(settings.DbPath);
var dirSize = DirSize(dir);
return dirSize;
}
catch
{
return -1;
}
}

static long DirSize(DirectoryInfo d)
{
long size = 0;
FileInfo[] fis = d.GetFiles();
foreach (FileInfo fi in fis)
{
size += fi.Length;
}
DirectoryInfo[] dis = d.GetDirectories();
foreach (DirectoryInfo di in dis)
{
return 0;
size += DirSize(di);
}
return size;
}

void RecordStartup(LoggingSettings loggingSettings, EndpointConfiguration endpointConfiguration)
{
var version = FileVersionInfo.GetVersionInfo(typeof(Bootstrapper).Assembly.Location).ProductVersion;
var dataSize = DataSize();
var folderSize = FolderSize();
var startupMessage = $@"
-------------------------------------------------------------
ServiceControl Version: {version}
Audit Retention Period (optional): {settings.AuditRetentionPeriod}
Error Retention Period: {settings.ErrorRetentionPeriod}
Ingest Error Messages: {settings.IngestErrorMessages}
Forwarding Error Messages: {settings.ForwardErrorMessages}
Database Size: {DataSize()} bytes
Database Size: {ByteSize.FromBytes(dataSize).ToString("#.##", CultureInfo.InvariantCulture)}
Database Folder Size: {ByteSize.FromBytes(folderSize).ToString("#.##", CultureInfo.InvariantCulture)}
ServiceControl Logging Level: {loggingSettings.LoggingLevel}
RavenDB Logging Level: {loggingSettings.RavenDBLogLevel}
Selected Transport Customization: {settings.TransportCustomizationType}
Expand Down Expand Up @@ -254,4 +288,4 @@ public ConstructorInfo[] FindConstructors(Type targetType)
static readonly ConcurrentDictionary<Type, ConstructorInfo[]> Cache = new ConcurrentDictionary<Type, ConstructorInfo[]>();
}
}
}
}
1 change: 1 addition & 0 deletions src/ServiceControl/ServiceControl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ByteSize" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.7" />
<PackageReference Include="Autofac.WebApi2" Version="4.3.1" />
Expand Down