This project creates a wrapper executable the can is used to the host any executable as a Windows service.
Download
The binaries is available here for download.
Usage
During Your development ...
- Take from
winsw.exe
the distribution, and rename it to your taste (such as myapp.exe
)
- Write
myapp.xml
(see Configuration Syntax for more details)
- Place those the files side by side If you deploy your application, because that's how to
winsw.exe
discovers its configuration.
At runtime ...
- To install a service, run
myapp.exe install
- To start a service, run
myapp.exe start
- To stop a service, run
myapp.exe stop
- To restart a service, run
myapp.exe restart
- To uninstall a service, run
myapp.exe uninstall
When there ' s a problem, these commands also the report an error message to stderr. On a successful completion, these commands does no produce any output and exit with 0.
In addition, you can also run to has it print out the current status of the myapp.exe status
service to stdout. Again, any error encountered during the processing would cause output to is reported to stderr.
All these commands with the same set of exit code to indicate its result.
Deferred File Operations
To the updating services, WINSW offers a mechanism to perform file operations before a service start up. This is often necessary because Windows prevents files from overwritten while it's in use.
To perform file operations, write a text file (in the UTF-8 encoding) at myapp.copies
(that's, it's in the same directory as But with a different file extension), and the operation add one line:
- To move a file, write "Src>dst". If the ' DST ' file already exists it'll be overwritten.
The success or failure of these operations would be recorded in the event log.
Windows Service Wrapper