mirror of https://github.com/winsw/winsw
Refactor yaml and xml support
Update naming conventions in Readme.md Remove ConfigType.cspull/641/head
parent
c15014f832
commit
5a533668af
|
@ -33,7 +33,7 @@ Binaries are available [here](https://repo.jenkins-ci.org/releases/com/sun/winsw
|
||||||
|
|
||||||
## Usage
|
## 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:
|
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
|
* [Installation guide](doc/installation.md) - Describes the installation process for different systems and .NET versions
|
||||||
* Configuration:
|
* Configuration:
|
||||||
* [Main XML configuration file](doc/xmlConfigFile.md)
|
* [Main XML configuration file](doc/xmlConfigFile.md)
|
||||||
* [Main YAML configuration file](doc/YamlConfigFile.md)
|
* [Main YAML configuration file](doc/yamlConfigFile.md)
|
||||||
* [EXE configuration file](doc/exeConfigFile.md)
|
|
||||||
* [Logging and error reporting](doc/loggingAndErrorReporting.md)
|
* [Logging and error reporting](doc/loggingAndErrorReporting.md)
|
||||||
* [Extensions](doc/extensions/extensions.md)
|
* [Extensions](doc/extensions/extensions.md)
|
||||||
* Use-cases:
|
* Use-cases:
|
||||||
|
|
|
@ -64,20 +64,8 @@ namespace WinSW
|
||||||
{
|
{
|
||||||
bool inConsoleMode = argsArray.Length > 0;
|
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 descriptor is not specified, initialize the new one (and load configs from there)
|
||||||
if (configType == ConfigType.XML)
|
descriptor = GetConfigType();
|
||||||
{
|
|
||||||
descriptor ??= new ServiceDescriptor(baseName, d);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
descriptor ??= new ServiceDescriptorYaml(baseName, d).Configurations;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure the wrapper-internal logging.
|
// Configure the wrapper-internal logging.
|
||||||
// STDOUT and STDERR of the child process will be handled independently.
|
// 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;
|
var executablePath = new DefaultWinSWSettings().ExecutablePath;
|
||||||
baseName = Path.GetFileNameWithoutExtension(executablePath);
|
var baseName = Path.GetFileNameWithoutExtension(executablePath);
|
||||||
|
|
||||||
if (baseName.EndsWith(".vshost"))
|
if (baseName.EndsWith(".vshost"))
|
||||||
{
|
{
|
||||||
baseName = baseName.Substring(0, baseName.Length - 7);
|
baseName = baseName.Substring(0, baseName.Length - 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
d = new DirectoryInfo(Path.GetDirectoryName(executablePath));
|
var d = new DirectoryInfo(Path.GetDirectoryName(executablePath));
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (File.Exists(Path.Combine(d.FullName, baseName + ".xml")))
|
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")))
|
if (File.Exists(Path.Combine(d.FullName, baseName + ".yml")))
|
||||||
{
|
{
|
||||||
return ConfigType.YAML;
|
return new ServiceDescriptorYaml(baseName, d).Configurations;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d.Parent is null)
|
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;
|
d = d.Parent;
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
namespace WinSW.Util
|
|
||||||
{
|
|
||||||
public enum ConfigType
|
|
||||||
{
|
|
||||||
XML,
|
|
||||||
YAML
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue