From a039ce356a9c3c41a63d864ed8c28a329ce2bb39 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 14 Nov 2017 12:45:48 +0900 Subject: [PATCH] ing --- glide.yaml | 2 -- main.go | 33 ++++++++++++++++++++++++++++++ server/server_handlers.go | 33 ++++++++++++++++++++++++++++++ servlet/web/servlet.go | 1 + servlet/web/subscriber_handlers.go | 2 ++ 5 files changed, 69 insertions(+), 2 deletions(-) delete mode 100644 glide.yaml create mode 100644 server/server_handlers.go create mode 100644 servlet/web/servlet.go create mode 100644 servlet/web/subscriber_handlers.go diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index 50d8072..0000000 --- a/glide.yaml +++ /dev/null @@ -1,2 +0,0 @@ -package: git.loafle.net/overflow/overflow_gateway_webapp -import: [] diff --git a/main.go b/main.go index 7905807..d02eb44 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,38 @@ package main +import ( + "fmt" + "log" + "os" + "os/signal" + "syscall" + + "git.loafle.net/commons_go/logging" + "git.loafle.net/overflow/overflow_gateway_webapp/server" + oogws "git.loafle.net/overflow/overflow_gateway_websocket/server" +) + func main() { + defer logging.Logger().Sync() + + sh := &server.ServerHandlers{} + s := oogws.New(sh) + + stop := make(chan os.Signal) + signal.Notify(stop, syscall.SIGINT) + + go func() { + if err := s.Start(); nil != err { + log.Printf("Server: Start error %v", err) + return + } + }() + + select { + case signal := <-stop: + fmt.Printf("Got signal: %v\n", signal) + } + + s.Stop() } diff --git a/server/server_handlers.go b/server/server_handlers.go new file mode 100644 index 0000000..7b5b343 --- /dev/null +++ b/server/server_handlers.go @@ -0,0 +1,33 @@ +package server + +import ( + cwfs "git.loafle.net/commons_go/websocket_fasthttp/server" +) + +type ServerHandlers struct { + cwfs.ServerHandlers +} + +// Init invoked before the server is started +// If you override ths method, must call +func (sh *ServerHandlers) Init() error { + if err := sh.ServerHandlers.Init(); nil != err { + return err + } + + return nil +} + +func (sh *ServerHandlers) OnStart() { + sh.ServerHandlers.OnStart() + +} + +func (sh *ServerHandlers) OnStop() { + + sh.ServerHandlers.OnStop() +} + +func (sh *ServerHandlers) Validate() { + sh.ServerHandlers.Validate() +} diff --git a/servlet/web/servlet.go b/servlet/web/servlet.go new file mode 100644 index 0000000..efb3895 --- /dev/null +++ b/servlet/web/servlet.go @@ -0,0 +1 @@ +package web diff --git a/servlet/web/subscriber_handlers.go b/servlet/web/subscriber_handlers.go new file mode 100644 index 0000000..24df326 --- /dev/null +++ b/servlet/web/subscriber_handlers.go @@ -0,0 +1,2 @@ +package web +