Beispiel #1
0
// 运行服务
func (s *Server) Run(args ...interface{}) {
	var eng engine.Engine
	var arg interface{}
	if len(args) > 0 {
		arg = args[0]
	}
	switch arg.(type) {
	case string:
		eng = standard.New(arg.(string))
	case engine.Engine:
		eng = args[0].(engine.Engine)
	default:
		eng = standard.New(`:80`)
	}
	defer func() {
		events.GoEvent(`webx.serverExit`, nil, func(_ bool) {})
	}()
	s.Core.Logger().Infof(`Server "%v" has been launched.`, s.Name)

	eng.SetHandler(s.ServeHTTP)
	eng.SetLogger(s.Core.Logger())
	eng.Start()

	s.Core.Logger().Infof(`Server "%v" has been closed.`, s.Name)
}
Beispiel #2
0
// Run starts the HTTP engine.
func (e *Echo) Run(eng engine.Engine) {
	e.engine = eng
	eng.SetHandler(e)
	eng.SetLogger(e.logger)
	if e.Debug() {
		e.logger.Debug("running in debug mode")
	}
	eng.Start()
}