windows svc sample

942 views
Skip to first unread message

Timothy Dewin

unread,
Dec 29, 2015, 2:27:56 PM12/29/15
to golang-nuts
Hi

Could not post issue on github so hope this arrives somewhere and not in the void

In the sample for Windows Service the following is stated
https://github.com/golang/sys/blob/master/windows/svc/example/install.go :
s, err = m.CreateService(name, exepath, mgr.Config{DisplayName: desc}, "is", "auto-started")

When I tried this sample (with some customization), the service instantly failed but if remove "is" "auto-started", it works. That would make sense because:
https://github.com/golang/sys/blob/master/windows/svc/mgr/mgr.go
states this would be extra arguments.

Proposing to remove those from the sample.

Timothy

Daniel Theophanes

unread,
Dec 29, 2015, 5:15:00 PM12/29/15
to golang-nuts
Hi Timothy,

I think the example works just fine. Having arguments for the installer is working as intended. If you'd like a simpler (slightly less powerful) API, there are two wrappers I've made around the windows/svc packages:

Do you think your program is crashing when it receives arguments it isn't expecting?

Timothy Dewin

unread,
Dec 30, 2015, 4:22:43 AM12/30/15
to golang-nuts
Hi,

You are right, it works fine in this sample. I see now that the main instantly starts the service if it find that the session is not interactive and thus ignore any arguments.

Anyway uploaded my sample (which is basically a copy/paste with small modifications) here. Instead of beeping, it just start a webservice.
https://github.com/tdewin/svcwindowssample/blob/master/svcwindowssample.go

Thanks!

Timothy
Reply all
Reply to author
Forward
0 new messages