diff --git a/README.md b/README.md index 63b50dd..5c74f45 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Binaries are available [here](https://repo.jenkins-ci.org/releases/com/sun/winsw ## Usage -WinSW is being managed by configuration files: [Main XML configuration file](doc/xmlConfigFile.md), [Main YML configuration file](doc/YamlConfigFile.md) and [EXE configuration file](doc/exeConfigFile.md). +WinSW is being managed by configuration files: [Main XML configuration file](doc/xmlConfigFile.md) and [Main YML configuration file](doc/yamlConfigFile.md). Your renamed *WinSW.exe* binary also accepts the following commands: @@ -59,8 +59,7 @@ User documentation: * [Installation guide](doc/installation.md) - Describes the installation process for different systems and .NET versions * Configuration: * [Main XML configuration file](doc/xmlConfigFile.md) - * [Main YAML configuration file](doc/YamlConfigFile.md) - * [EXE configuration file](doc/exeConfigFile.md) + * [Main YAML configuration file](doc/yamlConfigFile.md) * [Logging and error reporting](doc/loggingAndErrorReporting.md) * [Extensions](doc/extensions/extensions.md) * Use-cases: diff --git a/src/Core/ServiceWrapper/Program.cs b/src/Core/ServiceWrapper/Program.cs index c1fd861..2a39c24 100644 --- a/src/Core/ServiceWrapper/Program.cs +++ b/src/Core/ServiceWrapper/Program.cs @@ -64,20 +64,8 @@ namespace WinSW { bool inConsoleMode = argsArray.Length > 0; - string baseName; - DirectoryInfo d; - - var configType = GetConfigType(out baseName, out d); - // If descriptor is not specified, initialize the new one (and load configs from there) - if (configType == ConfigType.XML) - { - descriptor ??= new ServiceDescriptor(baseName, d); - } - else - { - descriptor ??= new ServiceDescriptorYaml(baseName, d).Configurations; - } + descriptor = GetConfigType(); // Configure the wrapper-internal logging. // STDOUT and STDERR of the child process will be handled independently. @@ -671,33 +659,33 @@ namespace WinSW } } - private static ConfigType GetConfigType(out string baseName, out DirectoryInfo d) + private static IWinSWConfiguration GetConfigType() { var executablePath = new DefaultWinSWSettings().ExecutablePath; - baseName = Path.GetFileNameWithoutExtension(executablePath); + var baseName = Path.GetFileNameWithoutExtension(executablePath); if (baseName.EndsWith(".vshost")) { baseName = baseName.Substring(0, baseName.Length - 7); } - d = new DirectoryInfo(Path.GetDirectoryName(executablePath)); + var d = new DirectoryInfo(Path.GetDirectoryName(executablePath)); while (true) { if (File.Exists(Path.Combine(d.FullName, baseName + ".xml"))) { - return ConfigType.XML; + return new ServiceDescriptor(baseName, d); } if (File.Exists(Path.Combine(d.FullName, baseName + ".yml"))) { - return ConfigType.YAML; + return new ServiceDescriptorYaml(baseName, d).Configurations; } if (d.Parent is null) { - throw new FileNotFoundException("Unable to locate " + baseName + ".xml " + "or " + baseName + ".yml " + "file within executable directory or any parents"); + throw new FileNotFoundException($"Unable to locate { baseName }.[xml|yml] file within executable directory or any parents"); } d = d.Parent; diff --git a/src/Core/WinSWCore/Util/ConfigType.cs b/src/Core/WinSWCore/Util/ConfigType.cs deleted file mode 100644 index 7989805..0000000 --- a/src/Core/WinSWCore/Util/ConfigType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace WinSW.Util -{ - public enum ConfigType - { - XML, - YAML - } -}