func Run() { defer func() { anaLog.Close() idl.Panic("shutdown") }() if config.AppLog.SlackLogUrl != "" { prio := priority.Warning if config.AnaLog.DevelopmentEnv { prio = priority.Debugging } idl.AddHook(&iDslackLog.SlackLogHook{ AcceptedPriorities: priority.Threshold(prio), HookURL: config.AppLog.SlackLogUrl, IconURL: "", Channel: "", IconEmoji: "", Username: "******", }) } idl.StandardLogger().Async = true idl.SetPrefix("anaLog") idl.SetErrCallback(func(err error) { idl.StandardLogger().Async = true idl.Log(&idl.Event{ idl.StandardLogger(), map[string]interface{}{ "error": err, }, time.Now(), priority.Emergency, "AppLogger caught an internal error", }) panic("AppLogger caught an internal error") }) if config.AnaLog.DevelopmentEnv { go scheduler.StartIn(1 * time.Second) } else { go scheduler.StartIn(10 * time.Second) } server.Listen() }
func connect2mgo() { var err error mgoSession, err = mgo.Dial(config.Mongo.Host) if err == nil { mgoSession.SetMode(mgo.Monotonic, true) if config.Mongo.User != "" && config.Mongo.Pass != "" { err = mgoSession.Login(&mgo.Credential{ Username: config.Mongo.User, Password: config.Mongo.Pass, }) } } if err != nil { idl.Panic(err) } }