diff --git a/cmd/tegola/cmd/server.go b/cmd/tegola/cmd/server.go index 323cf5165..c83e9e71a 100644 --- a/cmd/tegola/cmd/server.go +++ b/cmd/tegola/cmd/server.go @@ -1,6 +1,10 @@ package cmd import ( + "context" + "net/http" + "time" + "github.com/spf13/cobra" gdcmd "github.com/go-spatial/tegola/internal/cmd" @@ -50,3 +54,11 @@ var serverCmd = &cobra.Command{ }, } + +func shutdown(srv *http.Server) { + gdcmd.OnComplete(func() { + ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) + defer cancel() // releases resources if slowOperation completes before timeout elapses + srv.Shutdown(ctx) + }) +} diff --git a/cmd/tegola/cmd/server_shutdown.go b/cmd/tegola/cmd/server_shutdown.go deleted file mode 100644 index 40bef6ba7..000000000 --- a/cmd/tegola/cmd/server_shutdown.go +++ /dev/null @@ -1,20 +0,0 @@ -// +build go1.8 - -package cmd - -import ( - "context" - "net/http" - "time" - - gdcmd "github.com/go-spatial/tegola/internal/cmd" -) - -func shutdown(srv *http.Server) { - gdcmd.OnComplete(func() { - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() // releases resources if slowOperation completes before timeout elapses - srv.Shutdown(ctx) - }) - -} diff --git a/cmd/tegola/main.go b/cmd/tegola/main.go index 3f875d6e4..46b115e35 100644 --- a/cmd/tegola/main.go +++ b/cmd/tegola/main.go @@ -4,11 +4,11 @@ import ( "fmt" "os" + _ "github.com/theckman/goconstraint/go1.8/gte" + "github.com/go-spatial/tegola/cmd/tegola/cmd" ) -var codeLogFile *os.File - func main() { if err := cmd.RootCmd.Execute(); err != nil { fmt.Println(err) diff --git a/vendor/github.com/theckman/goconstraint/LICENSE b/vendor/github.com/theckman/goconstraint/LICENSE new file mode 100644 index 000000000..9403d8596 --- /dev/null +++ b/vendor/github.com/theckman/goconstraint/LICENSE @@ -0,0 +1,9 @@ +This package is released under two software licenses (MIT | Public Domain): + +* The `scripts/` directory is released under the MIT License. This license can + be found in the `LICENSES` directory as mit.txt [1]. +* All other files are released to the Public Domain using The Unlicense . This + license can be found in the `LICENSES` directory as unlicense.txt [2]. + +[1] https://github.com/theckman/goconstraint/blob/master/LICENSES/mit.txt +[2] https://github.com/theckman/goconstraint/blob/master/LICENSES/unlicense.txt diff --git a/vendor/github.com/theckman/goconstraint/go1.8/gte/constraint.go b/vendor/github.com/theckman/goconstraint/go1.8/gte/constraint.go new file mode 100644 index 000000000..24c248d60 --- /dev/null +++ b/vendor/github.com/theckman/goconstraint/go1.8/gte/constraint.go @@ -0,0 +1,8 @@ +// The contents of this file has been released in to the Public Domain. + +// Package gtego18 should only be used as a blank import. If imported, it +// will only compile if the Go runtime version is >= 1.8. +package gtego18 + +// This will fail to compile if the Go runtime version isn't >= 1.8. +var _ = __SOFTWARE_REQUIRES_GO_VERSION_1_8__ diff --git a/vendor/github.com/theckman/goconstraint/go1.8/gte/go18.go b/vendor/github.com/theckman/goconstraint/go1.8/gte/go18.go new file mode 100644 index 000000000..777fea4d6 --- /dev/null +++ b/vendor/github.com/theckman/goconstraint/go1.8/gte/go18.go @@ -0,0 +1,7 @@ +// The contents of this file has been released in to the Public Domain. + +// +build go1.8 + +package gtego18 + +const __SOFTWARE_REQUIRES_GO_VERSION_1_8__ = uint8(0) diff --git a/vendor/vendor.json b/vendor/vendor.json index 85c1afbc5..f945962e0 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -384,6 +384,12 @@ "revision": "329ebf1e04800d11a25047832495199d366580f3", "revisionTime": "2018-04-10T21:30:10Z" }, + { + "checksumSHA1": "jQ0wltHJ4nQ63Q+8Z6x0qhG91q4=", + "path": "github.com/theckman/goconstraint/go1.8/gte", + "revision": "e867bde6e4e19dde02a92e53627928770ee0ed41", + "revisionTime": "2018-02-16T22:48:03Z" + }, { "checksumSHA1": "i05c1J3Pkn6Ll+YINNnf6nv8z0g=", "path": "golang.org/x/tools/cmd/cover",