summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/sys/windows/svc/example/main.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-12-03 01:24:05 +0100
committerWim <wim@42.be>2017-12-03 01:24:05 +0100
commited9118b34620f1ecd5f28506328d4ffe1b04793d (patch)
tree442998012f6779446a463e402fa7c0836edcac91 /vendor/golang.org/x/sys/windows/svc/example/main.go
parent59e55cfbd5cc3c82236c5e8b95e5baff256f7143 (diff)
downloadmatterbridge-msglm-ed9118b34620f1ecd5f28506328d4ffe1b04793d.tar.gz
matterbridge-msglm-ed9118b34620f1ecd5f28506328d4ffe1b04793d.tar.bz2
matterbridge-msglm-ed9118b34620f1ecd5f28506328d4ffe1b04793d.zip
Add sshchat dependencies in vendor
Diffstat (limited to 'vendor/golang.org/x/sys/windows/svc/example/main.go')
-rw-r--r--vendor/golang.org/x/sys/windows/svc/example/main.go76
1 files changed, 76 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/windows/svc/example/main.go b/vendor/golang.org/x/sys/windows/svc/example/main.go
new file mode 100644
index 00000000..dc96c081
--- /dev/null
+++ b/vendor/golang.org/x/sys/windows/svc/example/main.go
@@ -0,0 +1,76 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build windows
+
+// Example service program that beeps.
+//
+// The program demonstrates how to create Windows service and
+// install / remove it on a computer. It also shows how to
+// stop / start / pause / continue any service, and how to
+// write to event log. It also shows how to use debug
+// facilities available in debug package.
+//
+package main
+
+import (
+ "fmt"
+ "log"
+ "os"
+ "strings"
+
+ "golang.org/x/sys/windows/svc"
+)
+
+func usage(errmsg string) {
+ fmt.Fprintf(os.Stderr,
+ "%s\n\n"+
+ "usage: %s <command>\n"+
+ " where <command> is one of\n"+
+ " install, remove, debug, start, stop, pause or continue.\n",
+ errmsg, os.Args[0])
+ os.Exit(2)
+}
+
+func main() {
+ const svcName = "myservice"
+
+ isIntSess, err := svc.IsAnInteractiveSession()
+ if err != nil {
+ log.Fatalf("failed to determine if we are running in an interactive session: %v", err)
+ }
+ if !isIntSess {
+ runService(svcName, false)
+ return
+ }
+
+ if len(os.Args) < 2 {
+ usage("no command specified")
+ }
+
+ cmd := strings.ToLower(os.Args[1])
+ switch cmd {
+ case "debug":
+ runService(svcName, true)
+ return
+ case "install":
+ err = installService(svcName, "my service")
+ case "remove":
+ err = removeService(svcName)
+ case "start":
+ err = startService(svcName)
+ case "stop":
+ err = controlService(svcName, svc.Stop, svc.Stopped)
+ case "pause":
+ err = controlService(svcName, svc.Pause, svc.Paused)
+ case "continue":
+ err = controlService(svcName, svc.Continue, svc.Running)
+ default:
+ usage(fmt.Sprintf("invalid command %s", cmd))
+ }
+ if err != nil {
+ log.Fatalf("failed to %s %s: %v", cmd, svcName, err)
+ }
+ return
+}