Skip to content

Commit

Permalink
Ignore service args
Browse files Browse the repository at this point in the history
Ignore -displayname and -servicename args that might be passed when running as a service depending on sc config options.
  • Loading branch information
DavidWiseman committed Apr 9, 2024
1 parent 2d80ff6 commit adcf40e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sql-log-shipping-service/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,13 @@ public void ValidateConfig()

public bool ApplyCommandLineOptions(string[] args)
{
var serviceArgs = new[] { "-displayname", "-servicename" };
if (args.Length == 0) return false;
// We might have -displayname or -servicename as arguments when running as a service. In this case we don't want to process the command line arguments
if (args.Any(arg => serviceArgs.Contains(arg, StringComparer.OrdinalIgnoreCase)))
{
return false;
}
var cfg = AppConfig.Config;

var errorCount = 0;
Expand Down Expand Up @@ -651,7 +657,7 @@ public bool ApplyCommandLineOptions(string[] args)
}
else
{
Log.Error("Configuration not updated. Please check the command line options.");
Log.Error("Configuration not updated. Please check the command line options.{args}",args);
Environment.Exit(1);
}

Expand Down

0 comments on commit adcf40e

Please sign in to comment.