本文整理汇总了Golang中server/libs/log.LogFatalf函数的典型用法代码示例。如果您正苦于以下问题:Golang LogFatalf函数的具体用法?Golang LogFatalf怎么用?Golang LogFatalf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LogFatalf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: StartAppBlance
func StartAppBlance(m *Master) {
for k, v := range m.AppArgs {
json, err := simplejson.NewJson(v)
if err != nil {
log.LogFatalf(err)
}
idx := 0
for {
app := json.GetIndex(idx)
if app.Interface() == nil {
break
}
appargs, _ := app.MarshalJSON()
appid, err := app.Get("id").String()
if err != nil {
log.LogFatalf("app id not set")
return
}
context.CreateApp("", appid, GetAppUid(), k, string(appargs), 0)
idx++
}
}
}
示例2: StartApp
func StartApp(m *Master) {
for k, v := range m.AppArgs {
json, err := simplejson.NewJson(v)
if err != nil {
log.LogFatalf(err)
}
idx := 0
startapp, ok := m.AppDef.Apps[k]
if !ok {
log.LogFatalf(errors.New("app not found"))
}
for {
app := json.GetIndex(idx)
if app.Interface() == nil {
break
}
appargs, _ := app.MarshalJSON()
name, err := app.Get("name").String()
if err != nil {
log.LogFatalf("app name not set")
return
}
Start(startapp, name, GetAppUid(), k, string(appargs))
idx++
}
}
}
示例3: RegisterRemote
func RegisterRemote(name string, remote interface{}) {
if remote == nil {
log.LogFatalf("rpc: Register remote is nil")
}
if _, dup := remotes[name]; dup {
log.LogFatalf("rpc: Register called twice for remote " + name)
}
remotes[name] = remote
}
示例4: RegisterHandler
func RegisterHandler(name string, handler interface{}) {
if handler == nil {
log.LogFatalf("rpc: Register handler is nil")
}
if _, dup := handlers[name]; dup {
log.LogFatalf("rpc: Register called twice for handler " + name)
}
handlers[name] = handler
}
示例5: Handle
func (mp *master_peer) Handle(id uint16, msgbody []byte) error {
switch id {
case share.M_ADD_SERVER:
var as share.AddApp
if err := share.DecodeMsg(msgbody, &as); err != nil {
return err
}
AddApp(as.Type, as.Id, as.Name, as.Host, as.Port, as.ClientHost, as.ClientPort, as.Ready, as.EnableGlobalData)
case share.M_REMOVE_SERVER:
var rs share.RemoveApp
if err := share.DecodeMsg(msgbody, &rs); err != nil {
return err
}
RemoveAppById(rs.Id)
case share.M_SERVER_LIST:
var sl share.AppInfo
if err := share.DecodeMsg(msgbody, &sl); err != nil {
return err
}
for _, a := range sl.Apps {
AddApp(a.Type, a.Id, a.Name, a.Host, a.Port, a.ClientHost, a.ClientPort, a.Ready, a.EnableGlobalData)
}
case share.M_HEARTBEAT:
data, err := util.CreateMsg(nil, []byte{}, share.M_HEARTBEAT)
if err != nil {
log.LogFatalf(err)
}
core.noder.Send(data)
case share.M_READY:
var ready share.AppReady
if err := share.DecodeMsg(msgbody, &ready); err != nil {
return err
}
app := GetAppById(ready.Id)
if app != nil {
app.SetReady(true)
} else {
log.LogFatalf("app not found")
}
case share.M_MUSTAPPREADY:
{
log.LogMessage("must app ready")
core.MustReady()
}
case share.M_SHUTDOWN:
core.Closing = true
close(core.exitChannel)
return nil
}
core.Emitter.Push(MASERTINMSG, map[string]interface{}{"msg": MasterMsg{id, msgbody}}, false)
return nil
}
示例6: Start
func Start(startapp string, name string, appuid int32, typ string, startargs string) error {
ferr, err := os.Create(fmt.Sprintf("log/%s_err.log", name))
if err != nil {
log.LogError(err)
return err
}
fout, err := os.Create(fmt.Sprintf("log/%s_trace.log", name))
if err != nil {
log.LogError(err)
return err
}
cmd := exec.Command(startapp, "-m", fmt.Sprintf("%s:%d", context.Host, context.Port), "-l", context.LocalIP, "-o", context.OuterIP, "-d", strconv.Itoa(int(appuid)), "-t", typ, "-s", startargs)
cmd.Stdout = fout
cmd.Stderr = ferr
err = cmd.Start()
if err != nil {
log.LogFatalf(err)
return err
}
log.TraceInfo("master", "app start ", typ, ",", strconv.Itoa(int(appuid)))
atomic.AddInt32(&Load, 1)
context.waitGroup.Wrap(func() {
cmd.Wait()
ferr.Close()
fout.Close()
log.LogMessage(name, " is quit")
atomic.AddInt32(&Load, -1)
})
return nil
}
示例7: Start
func (m *Master) Start() {
context = m
if !m.Agent {
log.TraceInfo("master", "start")
tcpListener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", m.Host, m.Port))
if err != nil {
log.LogError(err)
log.LogFatalf(err)
}
m.tcpListener = tcpListener
tcpserver := &tcp_server{}
m.waitGroup.Wrap(func() { util.TCPServer(m.tcpListener, tcpserver) })
}
if !m.Agent && m.ConsolePort != 0 {
StartConsoleServer(m)
log.LogMessage("console start at:", m.ConsolePort)
}
if m.Agent {
log.TraceInfo("master agent", "start")
m.agent = &Agent{}
m.agent.Connect(m.Host, m.Port, true, m.ConnectToMaster)
} else {
m.agentlist = NewAgentList()
m.waitfor = true
if m.WaitAgents == 0 {
m.waitfor = false
StartApp(m)
}
}
}
示例8: AddPlayerBak
func (a *AreaBridge) AddPlayerBak(mailbox rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) {
r := server.NewMessageReader(msg)
res, err := r.ReadString()
if server.Check(err) {
return 0, nil
}
if res == "ok" {
player := App.Players.GetPlayer(mailbox.Id)
if player == nil {
log.LogFatalf("can not be nil")
return 0, nil
}
if player.State != STATE_ENTERAREA { //可能客户端已经断开了,则让玩家下线
player.Leave()
return 0, nil
}
player.EnterScene()
return 0, nil
} else {
err := &s2c.Error{}
err.ErrorNo = proto.Int32(share.ERROR_ROLE_ENTERAREA_ERROR)
server.Check(server.MailTo(nil, &mailbox, "error", err))
return 0, nil
}
}
示例9: Check
func (app *app) Check() {
app.lastcheck = time.Now()
heartbeat := time.NewTicker(5 * time.Second)
updatelist := time.NewTicker(time.Minute) //每分钟同步一下app列表
for !app.Shutdown {
select {
case <-heartbeat.C: //send heartbeat pkg
if time.Now().Sub(app.lastcheck).Seconds() > TIMEOUTSECS {
app.conn.Close()
return
}
data, err := util.CreateMsg(nil, []byte{}, share.M_HEARTBEAT)
if err != nil {
log.LogFatalf(err)
}
app.conn.Write(data)
case <-updatelist.C:
app.SendList()
case <-app.exit:
return
}
}
heartbeat.Stop()
updatelist.Stop()
}
示例10: load
func (this *Config) load() {
ids := helper.GetConfigIds("conf_configuration.csv")
if len(ids) == 0 {
log.LogWarning("conf_configuration.csv file load failed")
return
}
this.configMap = make(map[string]*KeyVal, len(ids))
for _, id := range ids {
conf := &KeyVal{}
if err := helper.LoadStructByFile("conf_configuration.csv", id, conf); err != nil {
log.LogFatalf(err)
continue
}
this.configMap[conf.UniqueName] = conf
}
log.LogMessage("conf_configuration.csv file load ok")
ids = helper.GetConfigIds("conf_bp_ratio.csv")
if len(ids) == 0 {
log.LogWarning("conf_bp_ratio.csv file load failed")
return
}
for _, id := range ids {
conf := &KeyVal{}
tmp := &PropRatio{}
if err := helper.LoadStructByFile("conf_bp_ratio.csv", id, tmp); err != nil {
log.LogFatalf(err)
continue
}
conf.UniqueName = "bp_" + tmp.ID
conf.Value = tmp.BTRatio
this.configMap[conf.UniqueName] = conf
}
log.LogMessage("conf_bp_ratio.csv file load ok")
}
示例11: Ready
func Ready(app *app) {
applock.Lock()
defer applock.Unlock()
out, err := share.CreateReadyMsg(app.id)
if err != nil {
log.LogFatalf(err)
}
ismustapp := false
for _, v := range context.AppDef.MustApps {
if app.typ == v {
mustapps[app.typ] = app.name
ismustapp = true
if len(mustapps) == len(context.AppDef.MustApps) {
log.LogMessage("must app ready")
}
break
}
}
var out1 []byte
if len(mustapps) == len(context.AppDef.MustApps) {
out1, err = share.CreateMustAppReadyMsg()
if err != nil {
log.LogFatalf(err)
}
}
for _, v := range context.app {
if v.id != app.id {
v.conn.Write(out)
}
if len(out1) > 0 { //mustapp 已经都启动了
if ismustapp { //当前是mustapp的ready,则给所有的app发送mustappready消息。
v.conn.Write(out1)
} else if v.id == app.id { //当前是其它应用的ready,而且mustapp都启动了,则只需要给当前的app发送mustappready就可以了
v.conn.Write(out1)
}
}
}
}
示例12: RemovePlayerBak
func (a *AreaBridge) RemovePlayerBak(mailbox rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) {
player := App.Players.GetPlayer(mailbox.Id)
if player == nil {
log.LogFatalf("can not be nil", mailbox)
return 0, nil
}
player.LeaveArea()
return 0, nil
}
示例13: parseInclude
func parseInclude(obj *Object) {
if obj.Include != "" {
if obj.Include == obj.Name {
log.LogFatalf(obj.Name, " include self")
}
parent := Defs[obj.Include]
if parent == nil {
log.LogFatalf(obj.Name, " include ", obj.Include, " not found")
}
if !parent.flag {
parseInclude(parent)
}
obj.Propertys = append(parent.Propertys, obj.Propertys...)
obj.Records = append(parent.Records, obj.Records...)
}
obj.flag = true
}
示例14: Register
func (a *Agent) Register(agentid string, nobalance bool) error {
out, err := share.CreateRegisterAgent(agentid, nobalance)
if err != nil {
log.LogFatalf(err)
}
if _, err := a.rwc.Write(out); err != nil {
return err
}
return nil
}
示例15: Ready
func (p *peer) Ready() error {
out, err := util.CreateMsg(nil, []byte{}, share.M_READY)
if err != nil {
log.LogFatalf(err)
}
if _, err := p.rwc.Write(out); err != nil {
return err
}
return nil
}