fix #44 Support Zero downtime restarts for go servers
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
78039e9968
commit
9ec678cca1
|
@ -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 [YAML](https://github.com/go-yaml/yaml) configuration.
|
||||||
* Support command line to send single Android or iOS notification.
|
* Support command line to send single Android or iOS notification.
|
||||||
* Support Web API to send push 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):
|
See the [YAML config example](config/config.yml):
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package gopush
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
api "github.com/appleboy/gin-status-api"
|
api "github.com/appleboy/gin-status-api"
|
||||||
|
"github.com/fvbock/endless"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -76,9 +77,9 @@ func GetMainEngine() *gin.Engine {
|
||||||
func RunHTTPServer() error {
|
func RunHTTPServer() error {
|
||||||
var err error
|
var err error
|
||||||
if PushConf.Core.SSL && PushConf.Core.CertPath != "" && PushConf.Core.KeyPath != "" {
|
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 {
|
} else {
|
||||||
err = GetMainEngine().Run(":" + PushConf.Core.Port)
|
err = endless.ListenAndServe(":"+PushConf.Core.Port, GetMainEngine())
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue