Ejemplo n.º 1
0
func (msg *UserMsgItem) SafeMapTimeoutCall(key interface{}) {
	// 超时未删除则保存到db
	c := common.MongoCollection(MSG_DB, MSG_USER_MSG_TABLE)
	if err := c.Insert(msg); err != nil {
		syslog.Info(err, *msg)
	}
}
Ejemplo n.º 2
0
func ConnectToNSQAndLookupd(r *nsq.Consumer, nsqAddrs []string, lookupd []string) error {
	for _, addrString := range nsqAddrs {
		syslog.Info("add nsqd addr %s", addrString)
		err := r.ConnectToNSQD(addrString)
		if err != nil {
			return errors.As(err, addrString)
		}
	}

	for _, addrString := range lookupd {
		syslog.Info("add lookupd addr %s", addrString)
		err := r.ConnectToNSQLookupd(addrString)
		if err != nil {
			return errors.As(err, addrString)
		}
	}

	return nil
}
Ejemplo n.º 3
0
func QiniuDeleteFiles(keys []string) error {
	if len(keys) == 0 {
		return nil
	}
	entryPathes := []rs.EntryPath{}
	for _, key := range keys {
		entryPathes = append(entryPathes, rs.EntryPath{Bucket: g_bucket_name, Key: key})
	}
	_, err := g_file_mgr.rsClient.BatchDelete(nil, entryPathes)
	if err != nil {
		syslog.Info(err, keys)
	}
	deleteFile(keys)
	return nil
}
Ejemplo n.º 4
0
func (this *ConsumerT) work() {
	this.waitGroup.Add(1)
	defer this.waitGroup.Done()
	exitNotify := this.waitGroup.ExitNotify()
	for {
		select {
		case <-exitNotify:
			return
		case msg := <-this.msgCh:
			if err := this.handle.HandleMessage(msg); err != nil {
				syslog.Info(err, msg)
			}
		}
	}
}
Ejemplo n.º 5
0
func (location *LocationInfo) GetLocationInfo() error {
	session := common.MongoGet()
	defer common.MongoPut(session)

	c := session.DB("du").C("location")

	selector := bson.M{"uid": location.Uid}

	iter := c.Find(selector).Iter()

	for iter.Next(&location) {
		syslog.Info("Uid: ", location.Uid, " AppKey: ", " Loc: ", location.Loc, " send time: ", location.SendTime)
	}

	if err := iter.Close(); err != nil {
		return errors.As(err, *location)
	}

	return nil
}
Ejemplo n.º 6
0
func syslogInit() {
	config := syslog.NewConfig()
	config.ModelName = *g_module_name
	config.LogLevel = *g_log_level
	//config.LogLevel = syslog.ALL_LEVEL

	config.ConsoleLog = *g_log_console_enable
	config.ConsoleLogLevel = *g_log_console_level

	config.FileLog = *g_log_file_enable
	config.FileName = *g_log_file
	config.Directory = *g_log_path
	config.FileLogLevel = *g_log_file_level

	config.MysqlLog = *g_log_mysql_enable
	config.MysqlLogLevel = *g_log_mysql_level
	config.Host = *g_mysql_host
	config.Database = *g_mysql_log_db
	config.User = *g_mysql_user
	config.Password = *g_mysql_pwd

	config.MongoLog = *g_log_mongo_enable
	config.MongoLogLevel = *g_log_mongo_level
	config.MongoAddr = *g_MongodbAddr

	config.NsqdLog = *g_log_nsq_client_enable
	config.NsqdAddrs = *g_log_nsqd_addrs
	config.NsqdLogLevel = *g_log_nsq_client_level
	if *g_log_nsq_server_enable == true {
		config.FileLog = false
		config.ConsoleLog = false
		config.MysqlLog = false
		config.MongoLog = false
		config.NsqdLog = false
	}

	config.NsqdSvrLog = *g_log_nsq_server_enable
	config.NsqdSvrConfig.FileLog = *g_log_file_enable
	config.NsqdSvrConfig.FileName = *g_log_file
	config.NsqdSvrConfig.Directory = *g_log_path
	config.NsqdSvrConfig.FileLogLevel = *g_log_file_level

	config.NsqdSvrConfig.NsqdLog = false // 必须false 避免死循环日志 *g_log_nsq_client_enable
	config.NsqdSvrConfig.NsqdAddrs = *g_log_nsqd_addrs
	config.NsqdSvrConfig.NsqdLogLevel = *g_log_nsq_client_level

	config.NsqdSvrConfig.MysqlLog = *g_log_mysql_enable
	config.NsqdSvrConfig.Database = *g_mysql_log_db
	config.NsqdSvrConfig.MysqlLogLevel = *g_log_mysql_level
	config.NsqdSvrConfig.Host = *g_mysql_host
	config.NsqdSvrConfig.User = *g_mysql_user
	config.NsqdSvrConfig.Password = *g_mysql_pwd

	config.NsqdSvrConfig.MongoLog = *g_log_mongo_enable
	config.NsqdSvrConfig.MongoLogLevel = *g_log_mongo_level
	config.NsqdSvrConfig.MongoAddr = *g_MongodbAddr

	config.NsqdSvrConfig.ConsoleLog = *g_log_console_enable
	config.NsqdSvrConfig.ConsoleLogLevel = *g_log_console_level
	syslog.SysLogInit(config)
	syslog.Info("syslog init success!")
}