1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // Package debug provides facilities to execute svc.Handler on console.
16 "golang.org/x/sys/windows/svc"
19 // Run executes service name by calling appropriate handler function.
20 // The process is running on console, unlike real service. Use Ctrl+C to
21 // send "Stop" command to your service.
22 func Run(name string, handler svc.Handler) error {
23 cmds := make(chan svc.ChangeRequest)
24 changes := make(chan svc.Status)
26 sig := make(chan os.Signal)
30 status := svc.Status{State: svc.Stopped}
34 cmds <- svc.ChangeRequest{svc.Stop, 0, 0, status}
35 case status = <-changes:
40 _, errno := handler.Execute([]string{name}, cmds, changes)
42 return syscall.Errno(errno)