Use Windows Service wrapper to quickly create a Windows service such as Nginx

Source: Internet
Author: User

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

 
   
  
  1.  myapp.exe install

4. If you want to uninstall, use the uninstall command

 
   
  
  1. myapp.exe uninstall

5. Restart

 
   
  
  1. myapp.exe restart
6: Stop
 
   
  
  1. myapp.exe stop
7: Start:
 
   
  
  1. 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

  
 
  1. <service>
  2. <id>nginx</id>
  3. <name>nginx</name>
  4. <description>nginx</description>
  5. <executable>c:\nginx\nginx.exe</executable>
  6. <logpath>c:\nginx\</logpath>
  7. <logmode>roll</logmode>
  8. <depend></depend>
  9. <startargument>-c</startargument>
  10. <startargument>c:\nginx\conf\nginx.conf</startargument>
  11. <startargument>-c</startargument>
  12. <startargument>c:\nginx</startargument>
  13. <stopexecutable>c:\nginx\nginx.exe</stopexecutable>
  14. <stopargument>-p</stopargument>
  15. <stopargument>c:\nginx</stopargument>
  16. <stopargument>-s</stopargument>
  17. <stopargument>stop</stopargument>
  18. </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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.