Reputation: 905
I want to run a exe
file as a window service.
Is there any golang
open source or any golang
api
to do this?
Thanks!
Upvotes: 2
Views: 1702
Reputation: 754
You can use exec Package that runs external commands, for example:
import "os/exec"
cmd := exec.Command("your_exe_file")
if err := cmd.Start(); err != nil{
log.Fatal(err)
}
for more info https://golang.org/pkg/os/exec/
Upvotes: -1
Reputation: 1118
Read the Documentation Here: https://godoc.org/golang.org/x/sys/windows/svc
import "golang.org/x/sys/windows/svc"
and then use
func Run(name string, handler Handler) error
to start it.
There's a whole lot of other functions that will be useful to you on the page I linked, so you should definitely look at that.
Upvotes: 4