Example #1
0
func Init(config config.Config) {
	debug := config.GetBool("log.debug")
	sys := config.GetBool("log.syslog")

	Debug = log.New(ioutil.Discard, "", 0)
	if sys {
		Info = newSyslogger(syslog.LOG_INFO)
		if debug {
			Debug = newSyslogger(syslog.LOG_DEBUG)
		}
	} else {
		Info = newLogger()
		if debug {
			Debug = newLogger()
		}
	}
}
Example #2
0
func Open(config config.Config, index *lsmtree.Index) (*Store, error) {
	path := config.GetString("store.path")
	dirPerm := config.GetIntString("store.dir_permissions")
	filePerm := config.GetIntString("store.file_permissions")
	s := Store{path, os.FileMode(dirPerm), os.FileMode(filePerm), index}

	if err := os.MkdirAll(s.crapPath(), s.dirPerm); err != nil {
		return nil, err
	}
	if err := util.CreateLockFile(s.lockPath(), s.filePerm); err != nil {
		return nil, err
	}

	if err := s.initStore(); err != nil {
		return nil, err
	}

	return &s, nil
}
Example #3
0
func Listen(config config.Config, store *store.Store) (net.Listener, error) {
	lis, err := net.Listen("tcp", config.GetString("network.listen_address"))
	if err != nil {
		return nil, err
	}

	go func() {
		for {
			sock, err := lis.Accept()
			if err != nil {
				panic(err)
			}

			conn := newConn(store, sock)
			go conn.handleConnection()
		}
	}()

	return lis, nil
}