Objective
Today introduces the use of a gadget. We all know that Windows service is a special kind of application, it has the advantage of being able to run in the background, relatively, it is more suitable for some applications that need to run without too much user intervention, which we call "service"
Writing Windows service is not difficult, especially if you have Visual Studio. But still have a lot of children's shoes feel slightly cumbersome, at the same time, if there are some other programs, we only get an EXE, or a bat, but want to let him run like a service, how to do?
The answer is that you can use one of the following tools, whose name is "Windows Service Wrapper, or WSW."
Basic use of WSW
The general steps to use are:
1. Download the latest version of WSW, put it in any location, modify it to any name you want, such as "myapp.exe"
2. Write an XML file with the same name as:myapp.xml
3. Installing using the Install command
myapp.exe install
4. If you want to uninstall, use the uninstall command
myapp.exe uninstall
5. Restart
myapp.exe restart
6: Stop
myapp.exe stop
7: Start:
myapp.exe start
Https://github.com/kohsuke/winsw
Configuration file Format Please refer to: HTTPS://GITHUB.COM/KOHSUKE/WINSW
An example of me is as follows
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<executable>c:\nginx\nginx.exe</executable>
<logpath>c:\nginx\</logpath>
<logmode>roll</logmode>
<depend></depend>
<startargument>-c</startargument>
<startargument>c:\nginx\conf\nginx.conf</startargument>
<startargument>-c</startargument>
<startargument>c:\nginx</startargument>
<stopexecutable>c:\nginx\nginx.exe</stopexecutable>
<stopargument>-p</stopargument>
<stopargument>c:\nginx</stopargument>
<stopargument>-s</stopargument>
<stopargument>stop</stopargument>
</service>
After running the install, you can see this service in Services.msc
Related knowledge
In the Windows system, there is a special kind of service, they are started with a special program (SVCHOST), as follows
So, what's the matter? Interested children's shoes can refer to http://www.howtogeek.com/howto/windows-vista/what-is-svchostexe-and-why-is-it-running/
On the Linux system, there is also a similar tool (and more powerful), supervisor, interested children's shoes can refer to
Http://supervisord.org/introduction.html
From for notes (Wiz)
Use Windows Service wrapper to quickly create a Windows service such as Nginx