ing
This commit is contained in:
parent
df00b0f0e7
commit
657796d456
|
@ -6,21 +6,26 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strconv"
|
||||
|
||||
"git.loafle.net/commons_go/logging"
|
||||
"git.loafle.net/commons_go/server"
|
||||
|
||||
oocu "git.loafle.net/overflow/overflow_commons_go/util"
|
||||
)
|
||||
|
||||
func NewServerHandler(pidPath string, serverName string, socketHandler SocketHandler) ServerHandler {
|
||||
func NewServerHandler(pidPath string, serverName string, socketHandler SocketHandler, services []interface{}, servicesToStartAndStop []reflect.Type) ServerHandler {
|
||||
pidPathABS, err := filepath.Abs(pidPath)
|
||||
if nil != err {
|
||||
logging.Logger().Panicf("Container: pid file path[%s] is not valid %v", pidPath, err)
|
||||
}
|
||||
|
||||
sh := &ServerHandlers{
|
||||
pidPath: pidPath,
|
||||
pidPathABS: pidPathABS,
|
||||
pidPath: pidPath,
|
||||
pidPathABS: pidPathABS,
|
||||
services: services,
|
||||
servicesToStartAndStop: servicesToStartAndStop,
|
||||
}
|
||||
|
||||
sh.Name = serverName
|
||||
|
@ -34,6 +39,9 @@ type ServerHandlers struct {
|
|||
pidPath string
|
||||
pidPathABS string
|
||||
port int
|
||||
|
||||
services []interface{}
|
||||
servicesToStartAndStop []reflect.Type
|
||||
}
|
||||
|
||||
func (sh *ServerHandlers) Init(serverCTX server.ServerContext) error {
|
||||
|
@ -41,6 +49,10 @@ func (sh *ServerHandlers) Init(serverCTX server.ServerContext) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := oocu.ExecuteStarters(sh.services, sh.servicesToStartAndStop, false); nil != err {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -81,6 +93,9 @@ func (sh *ServerHandlers) OnStop(serverCTX server.ServerContext) {
|
|||
}
|
||||
|
||||
func (sh *ServerHandlers) Destroy(serverCTX server.ServerContext) {
|
||||
if err := oocu.ExecuteStoppers(sh.services, sh.servicesToStartAndStop, true); nil != err {
|
||||
logging.Logger().Error(err)
|
||||
}
|
||||
|
||||
sh.ServerHandlers.Destroy(serverCTX)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user