markdownlint fixes

pull/608/head
NextTurn 2020-07-29 00:00:00 +08:00
parent 4d852bdbff
commit e459165281
No known key found for this signature in database
GPG Key ID: 17A0D50ADDE1A0C4
10 changed files with 63 additions and 62 deletions

View File

@ -17,13 +17,13 @@ You can open `src\winsw.sln` and then build and run tests from within Visual Stu
### Building ### Building
``` ```console
dotnet build src\winsw.sln dotnet build src\winsw.sln
``` ```
### Testing ### Testing
``` ```console
dotnet test src\Test\winswTests\winswTests.csproj dotnet test src\Test\winswTests\winswTests.csproj
``` ```

View File

@ -36,7 +36,7 @@ WinSW binaries are available on [GitHub Releases](https://github.com/winsw/winsw
Alternative sources: Alternative sources:
* [Maven packaging](https://github.com/jenkinsci/winsw-maven-packaging) for executables, hosted by the [Jenkins project](https://jenkins.io/). * [Maven packaging](https://github.com/jenkinsci/winsw-maven-packaging) for executables, hosted by the [Jenkins project](https://jenkins.io/).
Binaries are available [here](https://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/). Binaries are available [here](https://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/).
## Usage ## Usage

View File

@ -17,7 +17,7 @@ Installs the service.
### Usage ### Usage
``` ```console
winsw install [<path-to-config>] [--no-elevate] [--user|--username <username>] [--pass|--password <password>] winsw install [<path-to-config>] [--no-elevate] [--user|--username <username>] [--pass|--password <password>]
``` ```
@ -48,7 +48,7 @@ Uninstalls the service.
### Usage ### Usage
``` ```console
winsw uninstall [<path-to-config>] [--no-elevate] winsw uninstall [<path-to-config>] [--no-elevate]
``` ```
@ -71,7 +71,7 @@ Starts the service.
### Usage ### Usage
``` ```console
winsw start [<path-to-config>] [--no-elevate] winsw start [<path-to-config>] [--no-elevate]
``` ```
@ -94,7 +94,7 @@ Stops the service.
### Usage ### Usage
``` ```console
winsw stop [<path-to-config>] [--no-elevate] [--no-wait] winsw stop [<path-to-config>] [--no-elevate] [--no-wait]
``` ```
@ -125,7 +125,7 @@ Stops and then starts the service.
### Usage ### Usage
``` ```console
winsw restart [<path-to-config>] [--no-elevate] winsw restart [<path-to-config>] [--no-elevate]
``` ```
@ -152,7 +152,7 @@ Checks the status of the service.
### Usage ### Usage
``` ```console
winsw status [<path-to-config>] winsw status [<path-to-config>]
``` ```
@ -169,7 +169,7 @@ Checks if the service can be started and then stopped without installation.
### Usage ### Usage
``` ```console
winsw test [<path-to-config>] [--no-elevate] [--timeout <timeout>] [--no-break] winsw test [<path-to-config>] [--no-elevate] [--timeout <timeout>] [--no-break]
``` ```
@ -202,7 +202,7 @@ Refreshes the service properties without reinstallation.
### Usage ### Usage
``` ```console
winsw refresh [<path-to-config>] [--no-elevate] winsw refresh [<path-to-config>] [--no-elevate]
``` ```

View File

@ -1,6 +1,6 @@
# Deferred file operations # Deferred file operations
To support self updating services, winsw offers a mechanism to perform file operations before the process you specified in the configuration file gets launched. To support self updating services, winsw offers a mechanism to perform file operations before the process you specified in the configuration file gets launched.
This is often necessary because Windows prevents a file from being overwritten while it's in use. This is often necessary because Windows prevents a file from being overwritten while it's in use.
To perform file operations, write a text file (in the UTF-8 encoding) at *myapp.copies* To perform file operations, write a text file (in the UTF-8 encoding) at *myapp.copies*

View File

@ -18,6 +18,7 @@ The only way to create an external extension is to create a new extension DLL an
See the example in `src/Core/ServiceWrapper/winsw.csproj`. See the example in `src/Core/ServiceWrapper/winsw.csproj`.
Generic extension creation guideline: Generic extension creation guideline:
* Extension DLL should reference the `WinSWCore` library. * Extension DLL should reference the `WinSWCore` library.
* The extension should extend the `AbstractWinSWExtension` class. * The extension should extend the `AbstractWinSWExtension` class.
* The extension then can override event handlers offered by the upper class. * The extension then can override event handlers offered by the upper class.
@ -26,7 +27,7 @@ Generic extension creation guideline:
WinSW engine will automatically locate your extension using the class name in the [XML configuration file](../xml-config-file.md). WinSW engine will automatically locate your extension using the class name in the [XML configuration file](../xml-config-file.md).
See configuration samples provided for the extensions in the core. See configuration samples provided for the extensions in the core.
For extensions from external DLLs, the `className` field should also specify the assembly name. For extensions from external DLLs, the `className` field should also specify the assembly name.
It can be done via fully qualified class name or just by the `${CLASS_NAME}, ${ASSEMBLY_NAME}` declaration. It can be done via fully qualified class name or just by the `${CLASS_NAME}, ${ASSEMBLY_NAME}` declaration.
Please note that in the current versions of WinSW the binary compatibility of extension APIs **is not guaranteed**. Please note that in the current versions of WinSW the binary compatibility of extension APIs **is not guaranteed**.

View File

@ -9,7 +9,7 @@ Since: WinSW 2.0.
## Usage ## Usage
The extension can be configured via the [XML configuration file](../xml-config-file.md). The extension can be configured via the [XML configuration file](../xml-config-file.md).
Configuration sample: Configuration sample:
```xml ```xml

View File

@ -18,7 +18,7 @@ There are some details for each step available below.
### Step 2. Configuration file ### Step 2. Configuration file
You write the configuration file that defines your service. You write the configuration file that defines your service.
The example below is a primitive example being used in the Jenkins project: The example below is a primitive example being used in the Jenkins project:
```xml ```xml
@ -36,15 +36,15 @@ The example below is a primitive example being used in the Jenkins project:
The full specification of the configuration file is available [here](xml-config-file.md). The full specification of the configuration file is available [here](xml-config-file.md).
### Step 3. Service registration ### Step 3. Service registration
You can then install the service like: You can then install the service like:
``` ```console
myapp.exe install <OPTIONS> myapp.exe install <OPTIONS>
``` ```
... and you can use the exit code from these processes to determine whether the operation was successful. ... and you can use the exit code from these processes to determine whether the operation was successful.
Possible exit codes are described [here](https://docs.microsoft.com/windows/win32/cimwin32prov/create-method-in-class-win32-service#return-value). Possible exit codes are described [here](https://docs.microsoft.com/windows/win32/cimwin32prov/create-method-in-class-win32-service#return-value).
Beyond these error codes, all the non-zero exit code should be assumed as a failure. Beyond these error codes, all the non-zero exit code should be assumed as a failure.
The Installer can be also started with the `/p` option. The Installer can be also started with the `/p` option.

View File

@ -55,8 +55,8 @@ This configuration must accompany a nested `<pattern>` element, which specifies
</log> </log>
``` ```
The syntax of the pattern string is specified by [DateTime.ToString(String)](https://docs.microsoft.com/dotnet/api/system.datetime.tostring#System_DateTime_ToString_System_String_). The syntax of the pattern string is specified by [DateTime.ToString(String)](https://docs.microsoft.com/dotnet/api/system.datetime.tostring#System_DateTime_ToString_System_String_).
For example, in the above example, the log of Jan 1, 2013 gets written to `myapp.20130101.out.log` and `myapp.20130101.err.log`. For example, in the above example, the log of Jan 1, 2013 gets written to `myapp.20130101.out.log` and `myapp.20130101.err.log`.
## Roll by size and time mode ## Roll by size and time mode
@ -70,8 +70,8 @@ Works in a combination of roll size mode and roll time mode, if the log file get
</log> </log>
``` ```
The syntax of the pattern string is specified by [DateTime.ToString(String)](https://docs.microsoft.com/dotnet/api/system.datetime.tostring#System_DateTime_ToString_System_String_). The syntax of the pattern string is specified by [DateTime.ToString(String)](https://docs.microsoft.com/dotnet/api/system.datetime.tostring#System_DateTime_ToString_System_String_).
For example, in the above example, the log of Jan 1, 2013 gets written to `myapp.20130101.out.log` and `myapp.20130101.err.log`. For example, in the above example, the log of Jan 1, 2013 gets written to `myapp.20130101.out.log` and `myapp.20130101.err.log`.
The syntax of the autoRollAtTime is specified by [TimeSpan.ToString(String)](https://docs.microsoft.com/dotnet/api/system.timespan.tostring#System_TimeSpan_ToString_System_String_). The syntax of the autoRollAtTime is specified by [TimeSpan.ToString(String)](https://docs.microsoft.com/dotnet/api/system.timespan.tostring#System_TimeSpan_ToString_System_String_).
For example, in the above example, at the start of the day it will roll the file over. For example, in the above example, at the start of the day it will roll the file over.
@ -81,7 +81,6 @@ For example, in the above example, at the start of the day it will roll the file
:warning: This feature is reported to be broken in recent WinSW versions. :warning: This feature is reported to be broken in recent WinSW versions.
It is a potential subject for removal. It is a potential subject for removal.
```xml ```xml
<log mode="roll-by-size-time"> <log mode="roll-by-size-time">
<zipOlderThanNumDays>5</zipOlderThanNumDays> <zipOlderThanNumDays>5</zipOlderThanNumDays>

View File

@ -2,14 +2,14 @@
## Restart from the spawned process ## Restart from the spawned process
To support self-restarting services, winsw exposes `WINSW_EXECUTABLE` environment variable into the forked process, To support self-restarting services, winsw exposes `WINSW_EXECUTABLE` environment variable into the forked process,
which refers to the full path of *WinSW.exe* that's managing the service. which refers to the full path of *WinSW.exe* that's managing the service.
To restart the service from within, execute `%WINSW_EXECUTABLE% restart!`. To restart the service from within, execute `%WINSW_EXECUTABLE% restart!`.
Note that you are invoking `restart!` command, not `restart` command. Note that you are invoking `restart!` command, not `restart` command.
This hidden command is a flavor of the `restart` operation, This hidden command is a flavor of the `restart` operation,
where winsw creates another winsw process in a separate process group, where winsw creates another winsw process in a separate process group,
and restarts the service from there. and restarts the service from there.
This additional indirection is necessary because Windows Service Control Manager (SCM) will kill child processes recursively when it stops a service. This additional indirection is necessary because Windows Service Control Manager (SCM) will kill child processes recursively when it stops a service.
SCM doesn't provide the restart operation as an atomic operation either, so winsw implements restart by a sequence of stop and start. SCM doesn't provide the restart operation as an atomic operation either, so winsw implements restart by a sequence of stop and start.
The second winsw process in a separate process group ensures that winsw can survive this massacre to execute the start call. The second winsw process in a separate process group ensures that winsw can survive this massacre to execute the start call.

View File

@ -25,20 +25,20 @@ Example:
## Environment variable expansion ## Environment variable expansion
Configuration XML files can include environment variable expansions of the form `%Name%`. Configuration XML files can include environment variable expansions of the form `%Name%`.
Such occurrences, if found, will be automatically replaced by the actual values of the variables. Such occurrences, if found, will be automatically replaced by the actual values of the variables.
If an undefined environment variable is referenced, no substitution occurs. If an undefined environment variable is referenced, no substitution occurs.
Also, the service wrapper sets the environment variable `BASE` by itself, which points to a directory that contains the renamed *WinSW.exe*. Also, the service wrapper sets the environment variable `BASE` by itself, which points to a directory that contains the renamed *WinSW.exe*.
This is useful to refer to other files in the same directory. This is useful to refer to other files in the same directory.
Since this is an environment variable by itself, this value can be also accessed from the child process launched from the service wrapper. Since this is an environment variable by itself, this value can be also accessed from the child process launched from the service wrapper.
## Configuration entries ## Configuration entries
### id ### id
Specifies the ID that Windows uses internally to identify the service. Specifies the ID that Windows uses internally to identify the service.
This has to be unique among all the services installed in a system, This has to be unique among all the services installed in a system,
and it should consist entirely out of alpha-numeric characters. and it should consist entirely out of alpha-numeric characters.
### name ### name
@ -53,13 +53,13 @@ This gets displayed in Windows service manager when the service is selected.
### executable ### executable
This element specifies the executable to be launched. This element specifies the executable to be launched.
It can be either absolute path, or you can just specify the executable name and let it be searched from `PATH` (although note that the services often run in a different user account and therefore it might have different `PATH` than your shell does.) It can be either absolute path, or you can just specify the executable name and let it be searched from `PATH` (although note that the services often run in a different user account and therefore it might have different `PATH` than your shell does.)
### startmode ### startmode
This element specifies the start mode of the Windows service. This element specifies the start mode of the Windows service.
It can be one of the following values: Boot, System, Automatic, or Manual. It can be one of the following values: Boot, System, Automatic, or Manual.
For more information, see the [ChangeStartMode method](https://docs.microsoft.com/windows/win32/cimwin32prov/changestartmode-method-in-class-win32-service). For more information, see the [ChangeStartMode method](https://docs.microsoft.com/windows/win32/cimwin32prov/changestartmode-method-in-class-win32-service).
The default value is `Automatic`. The default value is `Automatic`.
@ -76,7 +76,8 @@ Windows service installation may fail in such case.
``` ```
### depend ### depend
Specify IDs of other services that this service depends on.
Specify IDs of other services that this service depends on.
When service `X` depends on service `Y`, `X` can only run if `Y` is running. When service `X` depends on service `Y`, `X` can only run if `Y` is running.
Multiple elements can be used to specify multiple dependencies. Multiple elements can be used to specify multiple dependencies.
@ -94,7 +95,7 @@ See the [Logging and error reporting](logging-and-error-reporting.md) page for m
### Arguments ### Arguments
The `<arguments>` element specifies the arguments to be passed to the executable. The `<arguments>` element specifies the arguments to be passed to the executable.
```xml ```xml
<arguments>arg1 arg2 arg3</arguments> <arguments>arg1 arg2 arg3</arguments>
@ -145,12 +146,12 @@ The post-stop command is executed when the service is stopping and after the mai
### stoptimeout ### stoptimeout
When the service is requested to stop, winsw first attempts to send a Ctrl+C signal, When the service is requested to stop, winsw first attempts to send a Ctrl+C signal,
then wait for up to 15 seconds for the process to exit by itself gracefully. then wait for up to 15 seconds for the process to exit by itself gracefully.
A process failing to do that (or if the process does not have a console), A process failing to do that (or if the process does not have a console),
then winsw resorts to calling [TerminateProcess function](https://docs.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminateprocess) to kill the service instantly. then winsw resorts to calling [TerminateProcess function](https://docs.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminateprocess) to kill the service instantly.
This optional element allows you to change this "15 seconds" value, so that you can control how long winsw gives the service to shut itself down. This optional element allows you to change this "15 seconds" value, so that you can control how long winsw gives the service to shut itself down.
See `<onfailure>` below for how to specify time duration: See `<onfailure>` below for how to specify time duration:
```xml ```xml
@ -167,19 +168,19 @@ This optional element can be specified multiple times if necessary to specify en
### interactive ### interactive
If this optional element is specified, the service will be allowed to interact with the desktop, such as by showing a new window and dialog boxes. If this optional element is specified, the service will be allowed to interact with the desktop, such as by showing a new window and dialog boxes.
If your program requires GUI, set this like the following: If your program requires GUI, set this like the following:
```xml ```xml
<interactive /> <interactive />
``` ```
Note that since the introduction UAC (Windows Vista and onward), services are no longer really allowed to interact with the desktop. Note that since the introduction UAC (Windows Vista and onward), services are no longer really allowed to interact with the desktop.
In those OSes, all that this does is to allow the user to switch to a separate window station to interact with the service. In those OSes, all that this does is to allow the user to switch to a separate window station to interact with the service.
### beeponshutdown ### beeponshutdown
This optional element is to emit [simple tones](https://docs.microsoft.com/windows/win32/api/utilapiset/nf-utilapiset-beep) when the service shuts down. This optional element is to emit [simple tones](https://docs.microsoft.com/windows/win32/api/utilapiset/nf-utilapiset-beep) when the service shuts down.
This feature should be used only for debugging, as some operating systems and hardware do not support this functionality. This feature should be used only for debugging, as some operating systems and hardware do not support this functionality.
### download ### download
@ -190,11 +191,11 @@ This operation runs when the service is started, before the application specifie
For servers requiring authentication some parameters must be specified depending on the type of authentication. Only the basic authentication requires additional sub-parameters. Supported authentication types are: For servers requiring authentication some parameters must be specified depending on the type of authentication. Only the basic authentication requires additional sub-parameters. Supported authentication types are:
* `none`: default, must not be specified * `none`: default, must not be specified
* `sspi`: Windows [Security Support Provider Interface](https://docs.microsoft.com/windows/win32/secauthn/sspi) including Kerberos, NTLM etc. * `sspi`: Windows [Security Support Provider Interface](https://docs.microsoft.com/windows/win32/secauthn/sspi) including Kerberos, NTLM etc.
* `basic`: Basic authentication, sub-parameters: * `basic`: Basic authentication, sub-parameters:
* `user="UserName"` * `user="UserName"`
* `password="Passw0rd"` * `password="Passw0rd"`
* `unsecureAuth="true": default="false"` * `unsecureAuth="true": default="false"`
The parameter `unsecureAuth` is only effective when the transfer protocol is HTTP - unencrypted data transfer. This is a security vulnerability because the credentials are send in clear text! For a SSPI authentication this is not relevant because the authentication tokens are encrypted. The parameter `unsecureAuth` is only effective when the transfer protocol is HTTP - unencrypted data transfer. This is a security vulnerability because the credentials are send in clear text! For a SSPI authentication this is not relevant because the authentication tokens are encrypted.
@ -204,6 +205,7 @@ By default, the `download` command does not fail the service startup if the oper
In order to force the download failure in such case, it is possible to specify the `failOnError` boolean attribute. In order to force the download failure in such case, it is possible to specify the `failOnError` boolean attribute.
To specify a custom proxy use the parameter `proxy` with the following formats: To specify a custom proxy use the parameter `proxy` with the following formats:
- With credentials: `http://USERNAME:PASSWORD@HOST:PORT/`. - With credentials: `http://USERNAME:PASSWORD@HOST:PORT/`.
- Without credentials: `http://HOST:PORT/`. - Without credentials: `http://HOST:PORT/`.
@ -222,7 +224,7 @@ Examples:
auth="basic" user="aUser" password="aPassw0rd" /> auth="basic" user="aUser" password="aPassw0rd" />
<download from="http://example.com/some.dat" to="%BASE%\some.dat" <download from="http://example.com/some.dat" to="%BASE%\some.dat"
proxy="http://aUser:aPassw0rd@192.168.1.5:80/" proxy="http://aUser:aPassw0rd@192.168.1.5:80/"
auth="basic" unsecureAuth="true" auth="basic" unsecureAuth="true"
user="aUser" password="aPassw0rd" /> user="aUser" password="aPassw0rd" />
``` ```
@ -247,7 +249,7 @@ This optional repeatable element controls the behaviour when the process launche
For example, the above configuration causes the service to restart in 10 seconds after the first failure, restart in 20 seconds after the second failure, then Windows will reboot if the service fails one more time. For example, the above configuration causes the service to restart in 10 seconds after the first failure, restart in 20 seconds after the second failure, then Windows will reboot if the service fails one more time.
Each element contains a mandatory `action` attribute, which controls what Windows SCM will do, and optional `delay` attribute, which controls the delay until the action is taken. Each element contains a mandatory `action` attribute, which controls what Windows SCM will do, and optional `delay` attribute, which controls the delay until the action is taken.
The legal values for action are: The legal values for action are:
* `restart`: restart the service * `restart`: restart the service
@ -256,7 +258,7 @@ The legal values for action are:
The possible suffix for the delay attribute is sec/secs/min/mins/hour/hours/day/days. If missing, the delay attribute defaults to 0. The possible suffix for the delay attribute is sec/secs/min/mins/hour/hours/day/days. If missing, the delay attribute defaults to 0.
If the service keeps failing and it goes beyond the number of `<onfailure>` configured, the last action will be repeated. If the service keeps failing and it goes beyond the number of `<onfailure>` configured, the last action will be repeated.
Therefore, if you just want to always restart the service automatically, simply specify one `<onfailure>` element like this: Therefore, if you just want to always restart the service automatically, simply specify one `<onfailure>` element like this:
```xml ```xml
@ -265,14 +267,13 @@ Therefore, if you just want to always restart the service automatically, simply
### resetfailure ### resetfailure
This optional element controls the timing in which Windows SCM resets the failure count. This optional element controls the timing in which Windows SCM resets the failure count.
For example, if you specify `<resetfailure>1 hour</resetfailure>` and your service continues to run longer than one hour, then the failure count is reset to zero. For example, if you specify `<resetfailure>1 hour</resetfailure>` and your service continues to run longer than one hour, then the failure count is reset to zero.
This affects the behaviour of the failure actions (see `<onfailure>` above). This affects the behaviour of the failure actions (see `<onfailure>` above).
In other words, this is the duration in which you consider the service has been running successfully. In other words, this is the duration in which you consider the service has been running successfully.
Defaults to 1 day. Defaults to 1 day.
### Security descriptor ### Security descriptor
The security descriptor string for the service in SDDL form. The security descriptor string for the service in SDDL form.
@ -299,7 +300,7 @@ To use a user account, specify a `<serviceaccount>` element like this:
The `<username>` is in the form `DomainName\UserName` or `UserName@DomainName`. If the account belongs to the built-in domain, you can specify `.\UserName`. The `<username>` is in the form `DomainName\UserName` or `UserName@DomainName`. If the account belongs to the built-in domain, you can specify `.\UserName`.
The `<allowservicelogon>` is optional. The `<allowservicelogon>` is optional.
If set to `true`, will automatically set the "Allow Log On As A Service" right to the listed account. If set to `true`, will automatically set the "Allow Log On As A Service" right to the listed account.
To use [Group Managed Service Accounts](https://docs.microsoft.com/windows-server/security/group-managed-service-accounts/group-managed-service-accounts-overview), append `$` to the account name and remove `<password>` element: To use [Group Managed Service Accounts](https://docs.microsoft.com/windows-server/security/group-managed-service-accounts/group-managed-service-accounts-overview), append `$` to the account name and remove `<password>` element:
@ -367,7 +368,7 @@ Optional. Prompts for a user name and a password.
### Working directory ### Working directory
Some services need to run with a working directory specified. Some services need to run with a working directory specified.
To do this, specify a `<workingdirectory>` element like this: To do this, specify a `<workingdirectory>` element like this:
```xml ```xml