In the Windows platform, the Nginx registration to the service, but also can start, stop and restart methods, the Internet did not find a good way.
That being the case, the only way to write the program is
Use C # to write, interested in can download source code to change: source Download
or download the compiled program directly, you need the. NET Framework 2.0 or. NET Framework 4.0 environment support
Download: program Download
Feature description, using your own defined bat script to implement custom Windows services, should be available for most applications such as nginx such as the inconvenient use of Windows services
Directory Structure and Description:
Install.bat: Install the service script, open with Notepad, modify "Set My=nginxservice", let my value be the service name you want to register, such as "Hello"
Mystart.bat: This script is the script that executes when the service starts, and can implement its own startup logic
Mystop.bat: This script is a script that executes when the service is stopped, and can implement its own stop logic
NginxService.exe: This file name needs to be modified, that is, to modify the service name you need to register, such as the above is configured as "Hello", then modified to "Hello.exe", as for why, see the source logic.
2.0 and 4.0 directories: exe that holds the NginxService.exe corresponding to the. NET Framework 2.0 and. NET Framework 4.0 environments
Nginx added to the Windows service is simple, you can change nothing, only need to install the corresponding. NET Framework Environment
Copy the four files to Nginx.exe's sibling directory, double-click Run Install.bat to install, and after installation you will see a service named "Nginxservice" added to the service, that is, it can start and restart Nginx service.
Hey, sometimes the way to solve problems is so simple.
If you have any questions, you may not be able to reply. [email protected], or [email protected]
Nginx Add to Windows service