diff options
author | Unknwon <u@gogs.io> | 2019-10-23 23:03:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-23 23:03:17 -0700 |
commit | 613139e7bef81d3573e7988a47eb6765f3de347a (patch) | |
tree | 49de7277898d3ff47a122c072568edb8ed4c9ac9 /vendor/github.com/gogs/minwinsvc/svc_windows.go | |
parent | fb100dbf98f02e4c631d142ff0f52ec29ee2f00c (diff) |
Enable Go modules (#5835)
* Remove vendor
* Enable Go modules
* ci: add command to fetch dependencies
* ci: update setting
* ci: update settings
* Require Go 1.11
* Rename module name to gogs.io/gogs
Diffstat (limited to 'vendor/github.com/gogs/minwinsvc/svc_windows.go')
-rw-r--r-- | vendor/github.com/gogs/minwinsvc/svc_windows.go | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/vendor/github.com/gogs/minwinsvc/svc_windows.go b/vendor/github.com/gogs/minwinsvc/svc_windows.go deleted file mode 100644 index e79755fa..00000000 --- a/vendor/github.com/gogs/minwinsvc/svc_windows.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2015 Daniel Theophanes. -// Use of this source code is governed by a zlib-style -// license that can be found in the LICENSE file.package service - -//+build windows - -package minwinsvc - -import ( - "os" - "sync" - - "golang.org/x/sys/windows/svc" -) - -var ( - onExit func() - guard sync.Mutex -) - -func init() { - interactive, err := svc.IsAnInteractiveSession() - if err != nil { - panic(err) - } - // While run as Windows service, it is not an interactive session, - // but we don't want hook execute to be treated as service, e.g. gogs.exe hook pre-receive. - if interactive || len(os.Getenv("SSH_ORIGINAL_COMMAND")) > 0 { - return - } - go func() { - _ = svc.Run("", runner{}) - - guard.Lock() - f := onExit - guard.Unlock() - - // Don't hold this lock in user code. - if f != nil { - f() - } - // Make sure we exit. - os.Exit(0) - }() -} - -func setOnExit(f func()) { - guard.Lock() - onExit = f - guard.Unlock() -} - -type runner struct{} - -func (runner) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (bool, uint32) { - const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown - changes <- svc.Status{State: svc.StartPending} - - changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted} - for { - c := <-r - switch c.Cmd { - case svc.Interrogate: - changes <- c.CurrentStatus - case svc.Stop, svc.Shutdown: - changes <- svc.Status{State: svc.StopPending} - return false, 0 - } - } - - return false, 0 -} |