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
1 change: 1 addition & 0 deletions DevProxy.Abstractions/Proxy/IProxyConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public interface IProxyConfiguration
LogLevel LogLevel { get; }
ReleaseType NewVersionNotification { get; }
bool NoFirstRun { get; set; }
bool NoWatch { get; set; }
Comment thread
waldekmastykarz marked this conversation as resolved.
int Port { get; set; }
bool Record { get; set; }
bool ShowTimestamps { get; }
Expand Down
12 changes: 12 additions & 0 deletions DevProxy/Commands/DevProxyCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ sealed class DevProxyCommand : RootCommand
Description = "The path to the configuration file"
};
internal const string NoFirstRunOptionName = "--no-first-run";
internal const string NoWatchOptionName = "--no-watch";
internal const string AsSystemProxyOptionName = "--as-system-proxy";
internal const string InstallCertOptionName = "--install-cert";
internal const string UrlsToWatchOptionName = "--urls-to-watch";
Expand Down Expand Up @@ -402,6 +403,11 @@ private void ConfigureCommand()
Description = "Skip the first run experience"
};

var noWatchOption = new Option<bool?>(NoWatchOptionName)
{
Description = "Disable automatic restart on configuration file changes"
};

var discoverOption = new Option<bool?>(DiscoverOptionName)
{
Description = "Run Dev Proxy in discovery mode"
Expand Down Expand Up @@ -529,6 +535,7 @@ private void ConfigureCommand()
ipAddressOption,
logLevelOption,
noFirstRunOption,
noWatchOption,
outputOption,
portOption,
recordOption,
Expand Down Expand Up @@ -613,6 +620,11 @@ private void ConfigureFromOptions(ParseResult parseResult)
{
_proxyConfiguration.NoFirstRun = noFirstRun.Value;
}
var noWatch = parseResult.GetValueOrDefault<bool?>(NoWatchOptionName);
if (noWatch is not null)
{
_proxyConfiguration.NoWatch = noWatch.Value;
}
var asSystemProxy = parseResult.GetValueOrDefault<bool?>(AsSystemProxyOptionName);
if (asSystemProxy is not null)
{
Expand Down
6 changes: 6 additions & 0 deletions DevProxy/Proxy/ConfigFileWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public static void Reset()

public Task StartAsync(CancellationToken cancellationToken)
{
if (_proxyConfiguration.NoWatch)
{
_logger.LogDebug("Configuration file watching is disabled");
return Task.CompletedTask;
}

var configFilePath = _proxyConfiguration.ConfigFile;
if (string.IsNullOrEmpty(configFilePath) || !File.Exists(configFilePath))
{
Expand Down
1 change: 1 addition & 0 deletions DevProxy/Proxy/ProxyConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public string ConfigFile
[JsonConverter(typeof(JsonStringEnumConverter))]
public LogLevel LogLevel { get; set; } = LogLevel.Information;
public bool NoFirstRun { get; set; }
public bool NoWatch { get; set; }
[JsonConverter(typeof(JsonStringEnumConverter))]
public ReleaseType NewVersionNotification { get; set; } = ReleaseType.Stable;
public int Port { get; set; } = 8000;
Expand Down
Loading