Although most programs are written under freebsd and linux. However, we have encountered a problem in windows recently, that is, how to enable a server written in Go language to automatically start when the server is started on windows.
Therefore, it cannot be set to start in run. It is more reliable to make the server into a window. However, at the time of design, the program was run in linux. Later, it was migrated to windows for some reason, and the window service was not considered during writing.
The basic steps are as follows:
1. Prepare instsrv.exe srvany.exe. These two files are downloaded from the attachment.
Instsrv.exe is used to register a service. The usage is as follows:
Usage: instsrv <service name> <exe location> to install a service,
Or: instsrv <service name> remove to remove a service
Of course, the SC command can also be used to operate the service.
2. Register a srvany.exe Service
Instsrv MyService location/to/srvany.exe
3. Modify the Registry: Put the executable file of the real service in the registry.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ services \ MyService \ Parameters]
"Application" = "D: \ go \ tester \ src \ signalserver \ server \ signalserver.exe"
"AppDirectory" = "D: \ go \ tester \ src \ signalserver \ server"
"AppParameters" = ""
You can also manually modify the information in the registry or save the information as exe.
MyService is the service name.
Application Service Executable File Path
Directory of AppDirectory Service Execution
AppParameters parameter information, which can be blank