Skip to content

Commit

Permalink
Merge pull request #70 from Clever/add-graceful-shutdown
Browse files Browse the repository at this point in the history
Add graceful shutdown
  • Loading branch information
rgarcia authored Nov 20, 2017
2 parents 8740a0a + 1ad559d commit 26ca354
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@
[[constraint]]
branch = "v1"
name = "gopkg.in/yaml.v1"

[[constraint]]
name = "gopkg.in/tylerb/graceful.v1"
version = "1.2.15"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
machine:
post:
- cd $HOME && git clone --depth 1 -v [email protected]: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:
Expand All @@ -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
5 changes: 4 additions & 1 deletion daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 26ca354

Please sign in to comment.