diff --git a/Gopkg.lock b/Gopkg.lock index 4a45f61..bd2a6cf 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -48,6 +48,12 @@ revision = "096364e316a52652d3493be702d8105d8d01db84" version = "v6.6.0" +[[projects]] + name = "gopkg.in/tylerb/graceful.v1" + packages = ["."] + revision = "4654dfbb6ad53cb5e27f37d99b02e16c1872fbbb" + version = "v1.2.15" + [[projects]] branch = "v1" name = "gopkg.in/yaml.v1" @@ -62,6 +68,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "b07472dbf6685d10a3a7d77c010201bc8078a8b33d0a25d7ef932c9a2d6d2825" + inputs-digest = "ea120c4cb72c3120dec6e5184ba2a59abbaec4138f40e07fbb5ce65abdeb249f" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 0f1ea33..db79556 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -37,3 +37,7 @@ [[constraint]] branch = "v1" name = "gopkg.in/yaml.v1" + +[[constraint]] + name = "gopkg.in/tylerb/graceful.v1" + version = "1.2.15" diff --git a/Makefile b/Makefile index de2c3f3..0fd5089 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true) TESTS := $(shell find . -name "*_test.go" | sed s/\.go// | grep -v "./vendor") BENCHES := $(addsuffix "_bench", $(TESTS)) .PHONY: test $(PKGS) run clean build-release install_deps -$(eval $(call golang-version-check,1.8)) +$(eval $(call golang-version-check,1.9)) test: $(PKGS) $(PKGS): golang-test-all-strict-deps diff --git a/circle.yml b/circle.yml index 3ca8934..9153900 100644 --- a/circle.yml +++ b/circle.yml @@ -1,7 +1,7 @@ machine: post: - cd $HOME && git clone --depth 1 -v git@github.com:clever/ci-scripts.git && cd ci-scripts && git show --oneline -s - - $HOME/ci-scripts/circleci/golang-install 1.8 + - $HOME/ci-scripts/circleci/golang-install 1.9 services: - docker checkout: @@ -17,11 +17,16 @@ test: post: - $HOME/ci-scripts/circleci/report-card $RC_DOCKER_USER $RC_DOCKER_PASS "$RC_DOCKER_EMAIL" $RC_GITHUB_TOKEN deployment: - all: + master: branch: master owner: Clever commands: - $HOME/ci-scripts/circleci/docker-publish $DOCKER_USER $DOCKER_PASS "$DOCKER_EMAIL" $DOCKER_ORG - make VERSION && make deb && cp deb/sphinx.deb sphinx-amd64.deb && $HOME/ci-scripts/circleci/github-release $GH_RELEASE_TOKEN sphinx-amd64.deb + non-master: + branch: /^(?!master$).*$/ + owner: Clever + commands: + - $HOME/ci-scripts/circleci/docker-publish $DOCKER_USER $DOCKER_PASS "$DOCKER_EMAIL" $DOCKER_ORG general: build_dir: ../.go_workspace/src/github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME diff --git a/daemon/daemon.go b/daemon/daemon.go index 772ea65..14530c2 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -15,6 +15,7 @@ import ( "github.com/Clever/sphinx/ratelimiter" "github.com/pborman/uuid" "gopkg.in/Clever/kayvee-go.v6/middleware" + "gopkg.in/tylerb/graceful.v1" ) // Daemon represents a daemon server @@ -48,7 +49,9 @@ func (d *daemon) Start() { if d.healthCheck.Enabled { setUpHealthCheckService(d.healthCheck.Port, d.healthCheck.Endpoint) } - log.Fatal(http.ListenAndServe(d.proxy.Listen, d)) + if err := graceful.RunWithErr(d.proxy.Listen, 30*time.Second, d); err != nil { + log.Fatal(err) + } return }