From 9ec678cca127d0bdd76bfdd48c6f2e9358be906d Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 12 Apr 2016 15:04:25 +0800 Subject: [PATCH 1/2] fix #44 Support Zero downtime restarts for go servers Signed-off-by: Bo-Yi Wu --- README.md | 1 + gorush/server.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b30c436..540a884 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ A push notification server using [Gin](https://github.com/gin-gonic/gin) framewo * Support [YAML](https://github.com/go-yaml/yaml) configuration. * Support command line to send single Android or iOS notification. * Support Web API to send push notification. +* Support zero downtime restarts for go servers using [endless](https://github.com/fvbock/endless). See the [YAML config example](config/config.yml): diff --git a/gorush/server.go b/gorush/server.go index 80733c0..e5ea23b 100644 --- a/gorush/server.go +++ b/gorush/server.go @@ -3,6 +3,7 @@ package gopush import ( "fmt" api "github.com/appleboy/gin-status-api" + "github.com/fvbock/endless" "github.com/gin-gonic/gin" "net/http" ) @@ -76,9 +77,9 @@ func GetMainEngine() *gin.Engine { func RunHTTPServer() error { var err error if PushConf.Core.SSL && PushConf.Core.CertPath != "" && PushConf.Core.KeyPath != "" { - err = GetMainEngine().RunTLS(":"+PushConf.Core.Port, PushConf.Core.CertPath, PushConf.Core.KeyPath) + err = endless.ListenAndServeTLS(":"+PushConf.Core.Port, PushConf.Core.CertPath, PushConf.Core.KeyPath, GetMainEngine()) } else { - err = GetMainEngine().Run(":" + PushConf.Core.Port) + err = endless.ListenAndServe(":"+PushConf.Core.Port, GetMainEngine()) } return err From 68a7b13e9ce0522f7b2b4810e26110289a8d4846 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 12 Apr 2016 15:16:24 +0800 Subject: [PATCH 2/2] [ci skip] remove echo variable in travis. Signed-off-by: Bo-Yi Wu --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d490a2..491bf5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,9 +29,6 @@ script: -service=travis-ci -repotoken=$COVERALLS_TOKEN after_success: - - echo $TRAVIS_PULL_REQUEST - - echo $TRAVIS_BRANCH - - echo $TRAVIS_GO_VERSION - test "$TRAVIS_BRANCH" == "master" && test "$TRAVIS_GO_VERSION" == "1.6" && test "$TRAVIS_PULL_REQUEST" == "false" && docker login -e="$DOCKER_EMAIL" -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" - test "$TRAVIS_BRANCH" == "master" && test "$TRAVIS_GO_VERSION" == "1.6"