From c5bba12d766154632c819029371efa7aa34a4e54 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 14 Dec 2016 00:08:36 +0800 Subject: [PATCH] remove zero downtime for windows. Signed-off-by: Bo-Yi Wu --- glide.lock | 8 ++++---- glide.yaml | 2 +- gorush/server.go | 13 ------------- gorush/server_unix.go | 20 ++++++++++++++++++++ gorush/server_windows.go | 18 ++++++++++++++++++ 5 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 gorush/server_unix.go create mode 100644 gorush/server_windows.go diff --git a/glide.lock b/glide.lock index c39f8cb..61d0929 100644 --- a/glide.lock +++ b/glide.lock @@ -1,8 +1,6 @@ -hash: f556af81603ead677d8a4395b7a30b82956364273348e8c90f53c0cd0f6b4809 -updated: 2016-12-13T21:51:55.200004656+08:00 +hash: cccd36b5dd331f04f363476ebc21becfa3650945e3fd0b41821871702bc04743 +updated: 2016-12-14T00:05:23.060124146+08:00 imports: -- name: github.com/appleboy/endless - version: d773d36255895bc52adcfe318727f5e30f401b8e - name: github.com/asdine/storm version: 00b2f2df7ab7af9db746b826649395628cb5374e subpackages: @@ -11,6 +9,8 @@ imports: - index - name: github.com/boltdb/bolt version: acc803f0ced151102ed51bf824f8709ebd6602bc +- name: github.com/fvbock/endless + version: 2cdc20a776897c0f406853c048c33e2c1a9f0ebf - name: github.com/gin-gonic/gin version: f931d1ea80ae95a6fc739213cdd9399bd2967fb6 subpackages: diff --git a/glide.yaml b/glide.yaml index 7870b75..dc4747a 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,8 +1,8 @@ package: github.com/appleboy/gorush import: - package: github.com/Sirupsen/logrus -- package: github.com/appleboy/endless - package: github.com/asdine/storm +- package: github.com/fvbock/endless - package: github.com/gin-gonic/gin - package: github.com/google/go-gcm - package: github.com/sideshow/apns2 diff --git a/gorush/server.go b/gorush/server.go index 3b79e90..eccee8f 100644 --- a/gorush/server.go +++ b/gorush/server.go @@ -2,7 +2,6 @@ package gorush import ( "fmt" - "github.com/appleboy/endless" "github.com/gin-gonic/gin" api "gopkg.in/appleboy/gin-status-api.v1" "net/http" @@ -81,15 +80,3 @@ func routerEngine() *gin.Engine { return r } - -// RunHTTPServer provide run http or https protocol. -func RunHTTPServer() error { - var err error - if PushConf.Core.SSL && PushConf.Core.CertPath != "" && PushConf.Core.KeyPath != "" { - err = endless.ListenAndServeTLS(":"+PushConf.Core.Port, PushConf.Core.CertPath, PushConf.Core.KeyPath, routerEngine()) - } else { - err = endless.ListenAndServe(":"+PushConf.Core.Port, routerEngine()) - } - - return err -} diff --git a/gorush/server_unix.go b/gorush/server_unix.go new file mode 100644 index 0000000..ff25ac4 --- /dev/null +++ b/gorush/server_unix.go @@ -0,0 +1,20 @@ +// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris + +package gorush + +import ( + "github.com/fvbock/endless" +) + +// RunHTTPServer provide run http or https protocol. +func RunHTTPServer() error { + var err error + + if PushConf.Core.SSL && PushConf.Core.CertPath != "" && PushConf.Core.KeyPath != "" { + err = endless.ListenAndServeTLS(":"+PushConf.Core.Port, PushConf.Core.CertPath, PushConf.Core.KeyPath, routerEngine()) + } else { + err = endless.ListenAndServe(":"+PushConf.Core.Port, routerEngine()) + } + + return err +} diff --git a/gorush/server_windows.go b/gorush/server_windows.go new file mode 100644 index 0000000..00245cd --- /dev/null +++ b/gorush/server_windows.go @@ -0,0 +1,18 @@ +package gorush + +import ( + "net/http" +) + +// RunHTTPServer provide run http or https protocol. +func RunHTTPServer() error { + var err error + + if PushConf.Core.SSL && PushConf.Core.CertPath != "" && PushConf.Core.KeyPath != "" { + err = http.ListenAndServeTLS(":"+PushConf.Core.Port, PushConf.Core.CertPath, PushConf.Core.KeyPath, routerEngine()) + } else { + err = http.ListenAndServe(":"+PushConf.Core.Port, routerEngine()) + } + + return err +}