Merge pull request #45 from appleboy/endless

fix #44 Support Zero downtime restarts for go servers
This commit is contained in:
Bo-Yi Wu 2016-04-12 02:16:42 -05:00
commit 8e6ec1210e
3 changed files with 4 additions and 5 deletions

View File

@ -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"

View File

@ -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):

View File

@ -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