Skip to content

Commit

Permalink
Merge pull request #25 from datalust/dev
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
nblumhardt authored Aug 10, 2017
2 parents fce039f + 98543b7 commit abba422
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 29 deletions.
36 changes: 18 additions & 18 deletions setup/SeqForwarder/SeqForwarder.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,60 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="cmpDA27922DC39ABEE4AED51766786E4CFD" Guid="{7475ACB0-99D7-427A-AEF1-110311CE08E2}">
<Component Id="cmpDA27922DC39ABEE4AED51766786E4CFD" Guid="{F436137E-CE57-43A4-991B-9A44B8945FB2}">
<File Id="fil35A245A4D0EADE39BA1ACE4C3747CE4D" KeyPath="yes" Source="$(var.BasePath)\Autofac.dll" />
</Component>
<Component Id="cmp2A2B27F5AD386D451F6AD02173DDB353" Guid="{1FD67E81-F77B-4635-9FA6-EBB8FA4D8210}">
<Component Id="cmp2A2B27F5AD386D451F6AD02173DDB353" Guid="{40D0656B-4690-4093-990D-0B6C7AD7D59D}">
<File Id="fil510301A614A8F3D47B8A045FFEEF1D35" KeyPath="yes" Source="$(var.BasePath)\favicon.ico" />
</Component>
<Component Id="cmp48154C856B87ADEC49D8FEE6179FF03A" Guid="{3013C741-672D-406B-8515-10721B4438B3}">
<Component Id="cmp48154C856B87ADEC49D8FEE6179FF03A" Guid="{39F0555B-FCF3-48B1-98DE-F8346D65BF92}">
<File Id="fil41AF613B08BA33B207F6DC83C4917150" KeyPath="yes" Source="$(var.BasePath)\LightningDB.dll" />
</Component>
<Component Id="cmpE6945F57B9DA8C7CEA0B4D3732ED5DA1" Guid="{5CF4FB8C-E8E4-4A42-8330-A60D1F334E1B}">
<Component Id="cmpE6945F57B9DA8C7CEA0B4D3732ED5DA1" Guid="{E8420008-1C25-4E11-9353-E1EF73E44D1A}">
<File Id="fil55EDE175360A943150E17C54B6CDBC10" KeyPath="yes" Source="$(var.BasePath)\lmdb.dll" />
</Component>
<Component Id="cmp940F32D6B688098DD3F9EDF199414DE3" Guid="{BD5B6F1B-CF9A-4816-A8E6-9E9095B22B9D}">
<Component Id="cmp940F32D6B688098DD3F9EDF199414DE3" Guid="{92FDB58F-4090-44B9-824F-5DE9FE224EEF}">
<File Id="filF29CAC3406B7FD281FE44DE872EE3058" KeyPath="yes" Source="$(var.BasePath)\Nancy.Bootstrappers.Autofac.dll" />
</Component>
<Component Id="cmp3C40385889C0A6C29C06D1F58520BED2" Guid="{CC5499C1-2B78-487E-8118-7FBAD58C3CDB}">
<Component Id="cmp3C40385889C0A6C29C06D1F58520BED2" Guid="{3A576705-097E-4336-8A46-B86B3109FDEA}">
<File Id="fil59B7CA28C1ADB6A9766F27CC284885BD" KeyPath="yes" Source="$(var.BasePath)\Nancy.dll" />
</Component>
<Component Id="cmp133280381E1480D0340F6512570B789F" Guid="{3517DDB4-55BE-4A73-8417-6C0434E1F37B}">
<Component Id="cmp133280381E1480D0340F6512570B789F" Guid="{17BAFEC9-7D84-432E-89A6-A198794701CD}">
<File Id="filD47E65C2D9809A6FA596D96A0C2EB0FF" KeyPath="yes" Source="$(var.BasePath)\Nancy.Hosting.Self.dll" />
</Component>
<Component Id="cmpBC4FC00A26E7D32479D42D3411317FC5" Guid="{58BA8010-6124-4872-8ACA-7A3842BE6E34}">
<Component Id="cmpBC4FC00A26E7D32479D42D3411317FC5" Guid="{C6B591EE-03A8-41CB-81FE-B2B5A4BC035E}">
<File Id="fil90A8AAD9FC612906D405476D61CEA3F4" KeyPath="yes" Source="$(var.BasePath)\Newtonsoft.Json.dll" />
</Component>
<Component Id="cmp48F8563799218FAA04FAE2C1421BB6DA" Guid="{3E782BAF-B553-42C2-991F-A6566CC9E743}">
<Component Id="cmp48F8563799218FAA04FAE2C1421BB6DA" Guid="{1CCE349A-B52E-4537-B77B-8C5DCCCDC5B7}">
<File Id="fil47156FA1F974CD586257EF7433CC7AFC" KeyPath="yes" Source="$(var.BasePath)\seq-forwarder.exe" />
</Component>
<Component Id="cmpAF5B86F5776989B653A9B1FB1ABE9AE4" Guid="{31E3208B-46B5-4660-B36E-D10AACCC8B42}">
<Component Id="cmpAF5B86F5776989B653A9B1FB1ABE9AE4" Guid="{4C2E8041-443D-4F47-B052-4E1278019641}">
<File Id="fil2DC8EDE65F4F2999916D0ABEF954E7B4" KeyPath="yes" Source="$(var.BasePath)\seq-forwarder.exe.config" />
</Component>

<Component Id="cmpDD8AD4E452E0AB61B8413D84427F77C5" Guid="{D684164E-3FFD-49E8-A262-8ABD2A978BA7}">
<Component Id="cmpDD8AD4E452E0AB61B8413D84427F77C5" Guid="{69A65624-2466-4007-B8D0-D91294B32883}">
<File Id="fil567042DA1EF022EA1732B2D41CD35C18" KeyPath="yes" Source="$(var.BasePath)\seq-forwarder.runtimeconfig.dev.json" />
</Component>
<Component Id="cmp30AC7CC962CC421371F7A74B5E392687" Guid="{D4DFDF0D-8816-4E3B-8C33-0F16C2180C85}">
<Component Id="cmp30AC7CC962CC421371F7A74B5E392687" Guid="{AB7228EA-867C-4EC7-A216-2539EA68492F}">
<File Id="fil4066CD1D25962146D2CA42A5EF06101C" KeyPath="yes" Source="$(var.BasePath)\seq-forwarder.runtimeconfig.json" />
</Component>
<Component Id="cmp74A2C73F11C177073B0A672936A0D5EB" Guid="{7B3E13EF-5770-4990-9314-7B65AD41FDD8}">
<Component Id="cmp74A2C73F11C177073B0A672936A0D5EB" Guid="{4E643A97-31C6-4B1D-A776-A28244D7C801}">
<File Id="fil1CF141D24266A4E5F331DDFE02166A27" KeyPath="yes" Source="$(var.BasePath)\Serilog.dll" />
</Component>
<Component Id="cmpC08CEB1C24E4A6DA79EE83CFD8BDCD60" Guid="{7833CC99-60E4-4BCD-9CF2-8DE25B544939}">
<Component Id="cmpC08CEB1C24E4A6DA79EE83CFD8BDCD60" Guid="{32BA14D9-35BF-4649-BFC9-E2AC7BA9071A}">
<File Id="filD89F64F083730E2B8CC0DEE7002EF506" KeyPath="yes" Source="$(var.BasePath)\Serilog.Formatting.Compact.dll" />
</Component>
<Component Id="cmp49818C715FF04B8E95F7B53BDDD323EF" Guid="{675CC458-8FEC-4144-AEBF-7042F14A7F41}">
<Component Id="cmp49818C715FF04B8E95F7B53BDDD323EF" Guid="{4D6B5A41-A0FA-418E-AED7-156B3D88F56C}">
<File Id="fil1A12B15365165DDBE60433B150808BEE" KeyPath="yes" Source="$(var.BasePath)\Serilog.Sinks.File.dll" />
</Component>
<Component Id="cmp02B65BB0E7725E00772221A054BE0F6D" Guid="{6889A366-45A3-4EC1-A79E-15E3945D90A4}">
<Component Id="cmp02B65BB0E7725E00772221A054BE0F6D" Guid="{D5A17B2E-FDA6-480D-9567-0186C6A18586}">
<File Id="fil6E564047DBBA2340E7D8DB33266CF3CA" KeyPath="yes" Source="$(var.BasePath)\Serilog.Sinks.Literate.dll" />
</Component>
<Component Id="cmp5F1AA7FFD17911A668851FA15EE0CD1E" Guid="{334BB22B-9C1A-47EB-809E-48F384F6AEA8}">
<Component Id="cmp5F1AA7FFD17911A668851FA15EE0CD1E" Guid="{41E0E1DD-DD60-459C-B9FD-87E28A5372B2}">
<File Id="fil6DF069D04BE2DE8E81DEBB4B1DE25568" KeyPath="yes" Source="$(var.BasePath)\Serilog.Sinks.RollingFile.dll" />
</Component>
<Directory Id="dir62ACF81DE3B90724F16085CDF3C192DC" Name="Attribution">
<Component Id="cmpF91E9B989C748AD221E3EBF6B096037C" Guid="{1C0B8A60-EE01-4766-884A-CA019B42E75C}">
<Component Id="cmpF91E9B989C748AD221E3EBF6B096037C" Guid="{A3308447-B12C-4F54-8ADA-B8DF3A3B3AE3}">
<File Id="fil8457E1AB783E7733E2D421ECA491A606" KeyPath="yes" Source="$(var.BasePath)\Attribution\Nancy Libraries License.txt" />
</Component>
</Directory>
Expand Down
4 changes: 2 additions & 2 deletions setup/SeqForwarder/SeqForwarderAdministration.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="cmpA649DFAC5833A09BC5492E5C226C50BD" Guid="{FE1C0837-45D6-4B9D-BE50-8FB2A21888F0}">
<Component Id="cmpA649DFAC5833A09BC5492E5C226C50BD" Guid="{013BFB6B-FF84-4F34-8302-A5012DF348C7}">
<File Id="fil630EA70A5DD949EB3016A19DB62D7BCB" KeyPath="yes" Source="$(var.AdminBasePath)\Seq.Forwarder.Administration.exe" />
</Component>
<Component Id="cmp22ACF32714AEFA537B3DC30C167F0AE2" Guid="{12D740EF-E3C1-42B7-B190-38F3E33BBC4B}">
<Component Id="cmp22ACF32714AEFA537B3DC30C167F0AE2" Guid="{12BAB057-4596-4FDD-9383-4909257EC36D}">
<File Id="fil14A4AC386DABFD6900783A399A6F7FA2" KeyPath="yes" Source="$(var.AdminBasePath)\Seq.Forwarder.Administration.exe.config" />
</Component>

Expand Down
12 changes: 7 additions & 5 deletions src/Seq.Forwarder/Cli/Commands/DumpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ protected override int Run(TextWriter cout)
try
{
var config = SeqForwarderConfig.Read(_storagePath.ConfigFilePath);
var buffer = new LogBuffer(_storagePath.BufferPath, config.Storage.BufferSizeBytes);
buffer.Enumerate((k, v) =>
using (var buffer = new LogBuffer(_storagePath.BufferPath, config.Storage.BufferSizeBytes))
{
var s = Encoding.UTF8.GetString(v);
Console.WriteLine(s);
});
buffer.Enumerate((k, v) =>
{
var s = Encoding.UTF8.GetString(v);
Console.WriteLine(s);
});
}
return 0;
}
catch (Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion src/Seq.Forwarder/Cli/Commands/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ILogger CreateLogger(LogEventLevel internalLoggingLevel, string internalLogPath)
.Enrich.FromLogContext()
.MinimumLevel.Is(internalLoggingLevel)
.WriteTo.RollingFile(
new CompactJsonFormatter(),
new RenderedCompactJsonFormatter(),
GetRollingLogFilePathFormat(internalLogPath),
fileSizeLimitBytes: 1024*1024);

Expand Down
6 changes: 4 additions & 2 deletions src/Seq.Forwarder/Cli/Commands/TruncateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ protected override int Run(TextWriter cout)
try
{
var config = SeqForwarderConfig.Read(_storagePath.ConfigFilePath);
var buffer = new LogBuffer(_storagePath.BufferPath, config.Storage.BufferSizeBytes);
buffer.Truncate();
using (var buffer = new LogBuffer(_storagePath.BufferPath, config.Storage.BufferSizeBytes))
{
buffer.Truncate();
}
return 0;
}
catch (Exception ex)
Expand Down
13 changes: 12 additions & 1 deletion src/Seq.Forwarder/Cli/Features/StoragePathFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

using System;
using System.IO;
using System.ServiceProcess;
using Seq.Forwarder.ServiceProcess;
using Seq.Forwarder.Util;

namespace Seq.Forwarder.Cli.Features
{
Expand All @@ -28,7 +31,7 @@ public string StorageRootPath
if (!string.IsNullOrWhiteSpace(_storageRoot))
return _storageRoot;

return GetDefaultStorageRoot();
return TryQueryInstalledStorageRoot() ?? GetDefaultStorageRoot();
}
}

Expand All @@ -51,5 +54,13 @@ string GetDefaultStorageRoot()
@"Seq",
"Forwarder"));
}

string TryQueryInstalledStorageRoot()
{
if (ServiceConfiguration.GetServiceStoragePath(SeqForwarderWindowsService.WindowsServiceName, new StringWriter(), out var storage))
return storage;

return null;
}
}
}
53 changes: 53 additions & 0 deletions src/Seq.Forwarder/Util/ServiceConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Linq;
using System.ServiceProcess;
using System.Text;
using Serilog;

namespace Seq.Forwarder.Util
{
Expand Down Expand Up @@ -51,5 +52,57 @@ public static bool GetServiceBinaryPath(ServiceController controller, TextWriter
path = line.Replace("BINARY_PATH_NAME : ", "");
return true;
}

static bool GetServiceCommandLine(string serviceName, TextWriter cout, out string path)
{
if (serviceName == null) throw new ArgumentNullException(nameof(serviceName));
if (cout == null) throw new ArgumentNullException(nameof(cout));

var sc = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "sc.exe");

var config = new StringBuilder();
if (0 != CaptiveProcess.Run(sc, "qc \"" + serviceName + "\"", l => config.AppendLine(l), cout.WriteLine))
{
cout.WriteLine("Could not query service path; ignoring.");
path = null;
return false;
}

var lines = config.ToString()
.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
.Select(l => l.Trim());

var line = lines
.SingleOrDefault(l => l.StartsWith("BINARY_PATH_NAME : "));

if (line == null)
{
cout.WriteLine("No existing binary path could be determined.");
path = null;
return false;
}

path = line.Replace("BINARY_PATH_NAME : ", "");
return true;
}

public static bool GetServiceStoragePath(string serviceName, StringWriter cout, out string storage)
{
if (serviceName == null) throw new ArgumentNullException(nameof(serviceName));
if (cout == null) throw new ArgumentNullException(nameof(cout));

string binpath;
if (GetServiceCommandLine(serviceName, new StringWriter(), out binpath) &&
binpath.Contains("--storage=\""))
{
var start = binpath.IndexOf("--storage=\"", StringComparison.Ordinal) + 11;
var chop = binpath.Substring(start);
storage = chop.Substring(0, chop.IndexOf('"'));
return true;
}

storage = null;
return false;
}
}
}

0 comments on commit abba422

Please sign in to comment.