Beispiel #1
0
// Start AdminApp http server.
// Its addr is defined in configuration file as adminhttpaddr and adminhttpport.
func (admin *AdminApp) Start(AdminHttpAddr string, AdminHttpPort int) {
	if len(schedule.AdminTaskList) > 0 {
		schedule.StartTask()
	}

	for p, f := range admin.routers {
		http.Handle(p, f)
	}

	addr := fmt.Sprintf("%s:%d", AdminHttpAddr, AdminHttpPort)
	l, err := net.Listen("tcp", addr)
	if err != nil {
		logger.Critical("Admin Listen error: ", err)
		return
	}

	logger.Infof("Admin Serve: %s", l.Addr())

	go func() {
		server := &http.Server{}
		err = server.Serve(l)
		if err != nil {
			logger.Critical("Admin Serve: ", err)
		}
	}()
}
Beispiel #2
0
func (this *action) do() {
	defer FreeAction(this)
	defer utils.DumpStackIfPanic(fmt.Sprintf("netlib.session.task.do exe error, packet type:%v", reflect.TypeOf(this.p)))

	watch := profile.TimeStatisticMgr.WatchStart(this.n)
	defer watch.Stop()

	h := GetHandler(this.packid)
	if h != nil {
		err := h.Process(this.s, this.p)
		if err != nil {
			logger.Infof("%v process error %v", this.n, err)
		}
	} else {
		logger.Infof("%v not registe handler", this.n)
	}
}