Skip to content

Commit

Permalink
Container cleanup, console logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tippmar-nr committed Jul 24, 2023
1 parent 1e3666e commit 42ad774
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public override void CopyToRemote()

public override void Start(string commandLineArguments, Dictionary<string, string> environmentVariables, bool captureStandardOutput = false, bool doProfile = true)
{
CleanupContainer();

var arguments = $"compose up --force-recreate";

var newRelicHomeDirectoryPath = DestinationNewRelicHomeDirectoryPath;
Expand Down Expand Up @@ -144,7 +146,14 @@ public override void Shutdown()
// stop and remove the container, no need to kill RemoteProcess, as it will die when this command runs
// wait up to 5 seconds for the app to terminate gracefully before forcefully closing it
Process.Start("docker", $"container stop {ContainerName} -t 5");
Process.Start("docker", $"container rm {ContainerName}");
CleanupContainer();
}

private void CleanupContainer()
{
// ensure there's no stray containers or images laying around
Process.Start("docker", $"container rm --force {ContainerName}");
Process.Start("docker", $"image rm --force {ContainerName}");
}

protected virtual void WaitForAppServerToStartListening(Process process, bool captureStandardOutput)
Expand All @@ -165,6 +174,8 @@ protected virtual void WaitForAppServerToStartListening(Process process, bool ca

if (!process.HasExited)
{
CleanupContainer();

try
{
//We need to attempt to clean up the process that did not successfully start.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ protected LinuxSmokeTest(T fixture, ITestOutputHelper output) : base(fixture)
{
var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);
configModifier.ConfigureFasterMetricsHarvestCycle(5);
configModifier.LogToConsole();
},
exerciseApplication: () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ public void SetLogLevel(string level)
level);
}

public void LogToConsole()
{
CommonUtils.ModifyOrCreateXmlAttributeInNewRelicConfig(_configFilePath, new[] { "configuration", "log" }, "console",
"true");
}

public void SetLogDirectory(string directoryName)
{
CommonUtils.ModifyOrCreateXmlAttributeInNewRelicConfig(_configFilePath, new[] { "configuration", "log" }, "directory",
Expand Down

0 comments on commit 42ad774

Please sign in to comment.