func (m *Master) CreateApp(reqid string, appid string, appuid int32, typ string, startargs string, callbackapp int32) { if appuid == 0 { appuid = GetAppUid() } if m.agentlist != nil { agent := m.agentlist.GetMinLoadAgent() if agent != nil { if agent.load < Load { //远程创建 err := agent.CreateApp(reqid, appid, appuid, typ, startargs, callbackapp) if err != nil && callbackapp != 0 { data, err := share.CreateAppBakMsg(reqid, appuid, err.Error()) if err != nil { log.LogFatalf(err) } m.SendToApp(callbackapp, data) } return } } } //本地创建 err := CreateApp(appid, appuid, typ, startargs) res := "ok" if err != nil { res = err.Error() } if callbackapp != 0 { data, err := share.CreateAppBakMsg(reqid, appuid, res) if err != nil { log.LogFatalf(err) } m.SendToApp(callbackapp, data) } }
func (a *Agent) CreateApp(create share.CreateApp) { err := CreateApp(create.AppName, create.AppUid, create.Type, create.Args) res := "ok" if err != nil { res = err.Error() log.LogError(err) } if create.CallApp != 0 { data, err := share.CreateAppBakMsg(create.ReqId, create.AppUid, res) if err != nil { log.LogError(err) return } out, err := share.CreateForwardMsg(create.CallApp, data) if err != nil { log.LogError(err) return } a.Send(out) } }