First commit with working windows service.

This commit is contained in:
Daniel Theophanes
2012-03-08 09:25:13 -08:00
commit b86ed93d86
5 changed files with 581 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
package main
import (
"fmt"
"os"
"../../service"
)
func main() {
var displayName = "Go Service Test2"
var ws = service.NewService("GoServiceTest2", displayName)
if len(os.Args) > 1 {
var err error
verb := os.Args[1]
switch verb {
case "install":
err = ws.Install()
if err != nil {
fmt.Printf("Failed to install: %s\n", err)
return
}
fmt.Printf("Service \"%s\" installed.\n", displayName)
case "remove":
err = ws.Remove()
if err != nil {
fmt.Printf("Failed to remove: %s\n", err)
return
}
fmt.Printf("Service \"%s\" removed.", displayName)
}
return
}
err := ws.Run(func() error {
// start
go doWork()
ws.LogInfo("I'm Running!")
return nil
}, func() error {
// stop
stopWork()
ws.LogInfo("I'm Stopping!")
return nil
})
if err != nil {
ws.LogError(err.Error())
}
}
func doWork() {
}
func stopWork() {
}