Skip to content

Commit

Permalink
Config file
Browse files Browse the repository at this point in the history
  • Loading branch information
sburmanoctopus committed Dec 13, 2023
1 parent 1120a48 commit f27c574
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class ClientAndTentacle: IAsyncDisposable
public TentacleClient TentacleClient { get; }
public TemporaryDirectory TemporaryDirectory { get; }
public RpcRetrySettings RpcRetrySettings { get; }
public string HomeDirectory { get; }

public LegacyTentacleClientBuilder LegacyTentacleClientBuilder()
{
Expand All @@ -34,9 +35,10 @@ public ClientAndTentacle(IHalibutRuntime halibutRuntime,
PortForwarder? portForwarder,
RunningTentacle runningTentacle,
TentacleClient tentacleClient,
TemporaryDirectory temporaryDirectory,
TemporaryDirectory temporaryDirectory,
RpcRetrySettings rpcRetrySettings,
ILogger logger)
ILogger logger,
string homeDirectory)
{
this.halibutRuntime = halibutRuntime;
Server = server;
Expand All @@ -45,6 +47,7 @@ public ClientAndTentacle(IHalibutRuntime halibutRuntime,
TentacleClient = tentacleClient;
TemporaryDirectory = temporaryDirectory;
RpcRetrySettings = rpcRetrySettings;
HomeDirectory = homeDirectory;
this.ServiceEndPoint = serviceEndPoint;
this.logger = logger.ForContext<ClientAndTentacle>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public async Task<ClientAndTentacle> Build(CancellationToken cancellationToken)

var temporaryDirectory = new TemporaryDirectory();
var tentacleExe = tentacleVersion == null ? TentacleExeFinder.FindTentacleExe(this.tentacleRuntime) : await TentacleFetcher.GetTentacleVersion(temporaryDirectory.DirectoryPath, tentacleVersion, tentacleRuntime, logger, cancellationToken);
string homeDirectory;

logger.Information($"Tentacle.exe location: {tentacleExe}");

Expand All @@ -206,6 +207,7 @@ public async Task<ClientAndTentacle> Build(CancellationToken cancellationToken)
pollingTentacleBuilder.InstallAsAService();
}

homeDirectory = pollingTentacleBuilder.HomeDirectory.DirectoryPath;
runningTentacle = await pollingTentacleBuilder.Build(logger, cancellationToken);

tentacleEndPoint = new ServiceEndPoint(runningTentacle.ServiceUri, runningTentacle.Thumbprint, serverHalibutRuntime.TimeoutsAndLimits);
Expand All @@ -222,6 +224,7 @@ public async Task<ClientAndTentacle> Build(CancellationToken cancellationToken)
listeningTentacleBuilder.InstallAsAService();
}

homeDirectory = listeningTentacleBuilder.HomeDirectory.DirectoryPath;
runningTentacle = await listeningTentacleBuilder.Build(logger, cancellationToken);

portForwarder = BuildPortForwarder(runningTentacle.ServiceUri.Port, null);
Expand Down Expand Up @@ -258,7 +261,7 @@ public async Task<ClientAndTentacle> Build(CancellationToken cancellationToken)
clientOptions,
tentacleServiceDecorator);

return new ClientAndTentacle(server.ServerHalibutRuntime, tentacleEndPoint, server, portForwarder, runningTentacle, tentacleClient, temporaryDirectory, retrySettings, logger);
return new ClientAndTentacle(server.ServerHalibutRuntime, tentacleEndPoint, server, portForwarder, runningTentacle, tentacleClient, temporaryDirectory, retrySettings, logger, homeDirectory);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public abstract class TentacleBuilder<T> : ITentacleBuilder

TemporaryDirectory? homeDirectory;

protected TemporaryDirectory HomeDirectory
public TemporaryDirectory HomeDirectory
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,20 +426,10 @@ public async Task ShouldLogStartupDiagnosticsToInstanceLogFileOnly(TentacleConfi
await using var clientAndTentacle = await tc.CreateBuilder().Build(CancellationToken);
Logger.Error($"*** Env Home2: {Environment.GetEnvironmentVariable(HomeConfiguration.OctopusHomeSettingName)}, {Environment.GetEnvironmentVariable(ApplicationConfigurationContributionFlag.ContributeSettingsFlag)}");

var machineConfigurationHomeDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Octopus");
if (!PlatformDetection.IsRunningOnWindows)
{
machineConfigurationHomeDirectory = "/etc/octopus";
}

var instanceFilePath = Path.Combine(machineConfigurationHomeDirectory, "Tentacle", "Instances", $"{clientAndTentacle.RunningTentacle.InstanceName}.config");
Logger.Information("######### INSTANCE FILE OG #########");
var instanceFile = File.ReadAllText(instanceFilePath);
var instance = JsonConvert.DeserializeObject<Instance>(instanceFile);
Logger.Information(Environment.NewLine + instanceFile);
Logger.Information("######### INSTANCE FILE OG #########");

Logger.Information("######### CONFIG FILE OG #########");
var configFile = File.ReadAllText(instance.ConfigurationFilePath);
var configFilePath = Path.Combine(clientAndTentacle.HomeDirectory, $"{clientAndTentacle.RunningTentacle.InstanceName}.cfg");
var configFile = File.ReadAllText(configFilePath);
Logger.Information(Environment.NewLine + configFile);
Logger.Information("######### CONFIG FILE OG #########");

Expand Down Expand Up @@ -547,7 +537,7 @@ public async Task ShouldLogStartupDiagnosticsToInstanceLogFileOnly(TentacleConfi
}

Logger.Information("######### CONFIG FILE 2 #########");
configFile = File.ReadAllText(instance.ConfigurationFilePath);
configFile = File.ReadAllText(configFilePath);
Logger.Information(Environment.NewLine + configFile);
Logger.Information("######### CONFIG FILE 2 #########");

Expand Down

0 comments on commit f27c574

Please sign in to comment.