mirror of https://github.com/winsw/winsw
Remove `<*argument>`
parent
cd951e69df
commit
db91805e45
|
@ -94,33 +94,36 @@ See the [Logging and error reporting](logging-and-error-reporting.md) page for m
|
|||
|
||||
### Arguments
|
||||
|
||||
`<argument>` element specifies the arguments to be passed to the executable.
|
||||
Winsw will quote each argument if necessary, so do not put quotes in `<argument>` to avoid double quotation.
|
||||
The `<arguments>` element specifies the arguments to be passed to the executable.
|
||||
|
||||
```xml
|
||||
<argument>arg1</argument>
|
||||
<argument>arg2</argument>
|
||||
<argument>arg3</argument>
|
||||
<arguments>arg1 arg2 arg3</arguments>
|
||||
```
|
||||
|
||||
`<arguments>` element can be used instead to specify the whole command line in a single element.
|
||||
-or-
|
||||
|
||||
```xml
|
||||
<arguments>
|
||||
arg1
|
||||
arg2
|
||||
arg3
|
||||
</arguments>
|
||||
|
||||
### stopargument/stopexecutable
|
||||
|
||||
~~When the service is requested to stop, winsw simply calls [TerminateProcess function](https://docs.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminateprocess) to kill the service instantly.~~
|
||||
However, if `<stopargument>`/`<stoparguments>` elements are present, winsw will instead launch another process of `<executable>` (or `<stopexecutable>` if that's specified) with the specified arguments, and expects that to initiate the graceful shutdown of the service process.
|
||||
However, if the `<stoparguments>` element is present, winsw will instead launch another process of `<executable>` (or `<stopexecutable>` if that's specified) with the specified arguments, and expects that to initiate the graceful shutdown of the service process.
|
||||
|
||||
Winsw will then wait for the two processes to exit on its own, before reporting back to Windows that the service has terminated.
|
||||
|
||||
When you use the `<stopargument>`/`<stoparguments>`, you must use `<startargument>`/`<startarguments>` instead of `<argument>`. See the complete example below:
|
||||
When you use the `<stoparguments>`, you must use `<startarguments>` instead of `<arguments>`. See the complete example below:
|
||||
|
||||
```xml
|
||||
<executable>catalina.sh</executable>
|
||||
<startargument>jpda</startargument>
|
||||
<startargument>run</startargument>
|
||||
<startarguments>jpda run</startarguments>
|
||||
|
||||
<stopexecutable>catalina.sh</stopexecutable>
|
||||
<stopargument>stop</stopargument>
|
||||
<stoparguments>stop</stoparguments>
|
||||
```
|
||||
|
||||
### Additional commands
|
||||
|
|
|
@ -220,61 +220,37 @@ namespace WinSW
|
|||
public string? StopExecutable => this.SingleElement("stopexecutable", true);
|
||||
|
||||
/// <summary>
|
||||
/// <c>arguments</c> or multiple optional <c>argument</c> elements which overrule the arguments element.
|
||||
/// The <c>arguments</c> element.
|
||||
/// </summary>
|
||||
public string Arguments
|
||||
{
|
||||
get
|
||||
{
|
||||
string? arguments = this.AppendTags("argument", null);
|
||||
|
||||
if (!(arguments is null))
|
||||
{
|
||||
return arguments;
|
||||
}
|
||||
|
||||
XmlNode? argumentsNode = this.dom.SelectSingleNode("//arguments");
|
||||
|
||||
return argumentsNode is null ? Defaults.Arguments : Environment.ExpandEnvironmentVariables(argumentsNode.InnerText);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>startarguments</c> or multiple optional <c>startargument</c> elements.
|
||||
/// The <c>startarguments</c> element.
|
||||
/// </summary>
|
||||
public string? StartArguments
|
||||
{
|
||||
get
|
||||
{
|
||||
string? startArguments = this.AppendTags("startargument", null);
|
||||
|
||||
if (!(startArguments is null))
|
||||
{
|
||||
return startArguments;
|
||||
}
|
||||
|
||||
XmlNode? startArgumentsNode = this.dom.SelectSingleNode("//startarguments");
|
||||
|
||||
return startArgumentsNode is null ? null : Environment.ExpandEnvironmentVariables(startArgumentsNode.InnerText);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>stoparguments</c> or multiple optional <c>stopargument</c> elements.
|
||||
/// The <c>stoparguments</c> element.
|
||||
/// </summary>
|
||||
public string? StopArguments
|
||||
{
|
||||
get
|
||||
{
|
||||
string? stopArguments = this.AppendTags("stopargument", null);
|
||||
|
||||
if (!(stopArguments is null))
|
||||
{
|
||||
return stopArguments;
|
||||
}
|
||||
|
||||
XmlNode? stopArgumentsNode = this.dom.SelectSingleNode("//stoparguments");
|
||||
|
||||
return stopArgumentsNode is null ? null : Environment.ExpandEnvironmentVariables(stopArgumentsNode.InnerText);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,40 +331,6 @@ $@"<service>
|
|||
Assert.Equal("arg", sd.Arguments);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Arguments_NewParam_Single()
|
||||
{
|
||||
var sd = ConfigXmlBuilder.Create(this.output)
|
||||
.WithTag("argument", "--arg1=2")
|
||||
.ToServiceDescriptor(true);
|
||||
Assert.Equal(" --arg1=2", sd.Arguments);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Arguments_NewParam_MultipleArgs()
|
||||
{
|
||||
var sd = ConfigXmlBuilder.Create(this.output)
|
||||
.WithTag("argument", "--arg1=2")
|
||||
.WithTag("argument", "--arg2=123")
|
||||
.WithTag("argument", "--arg3=null")
|
||||
.ToServiceDescriptor(true);
|
||||
Assert.Equal(" --arg1=2 --arg2=123 --arg3=null", sd.Arguments);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that the new single-argument field has a higher priority.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Arguments_Bothparam_Priorities()
|
||||
{
|
||||
var sd = ConfigXmlBuilder.Create(this.output)
|
||||
.WithTag("arguments", "--arg1=2 --arg2=3")
|
||||
.WithTag("argument", "--arg2=123")
|
||||
.WithTag("argument", "--arg3=null")
|
||||
.ToServiceDescriptor(true);
|
||||
Assert.Equal(" --arg2=123 --arg3=null", sd.Arguments);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
|
|
Loading…
Reference in New Issue