<commit_before>package cli

import (
	"net"
	"path"

	"github.com/asdine/lobby"
	"github.com/asdine/lobby/bolt"
	"github.com/asdine/lobby/rpc"
	cli "gopkg.in/urfave/cli.v1"
)

const (
	defaultAddr = ":5656"
)

func newRunCmd(a *app) cli.Command {
	cmd := runCmd{
		app: a,
	}

	return cli.Command{
		Name:   "run",
		Usage:  "Run Lobby",
		Action: cmd.run,
	}
}

type runCmd struct {
	app     *app
	mainSrv lobby.Server
}

func (s *runCmd) run(_ *cli.Context) error {
	return s.runMainServer()
}

func (s *runCmd) runMainServer() error {
	err := s.app.loadBackendPlugins()
	if err != nil {
		return err
	}

	dataPath := path.Join(s.app.DataDir, "bolt")
	registryPath := path.Join(dataPath, "registry.db")

	err = initDir(dataPath)
	if err != nil {
		return err
	}

	reg, err := bolt.NewRegistry(registryPath)
	if err != nil {
		return err
	}

	for _, p := range s.app.Backends {
		bck, err := p.Backend()
		if err != nil {
			return err
		}

		reg.RegisterBackend(p.Name(), bck)
	}

	srv := rpc.NewServer(rpc.WithBucketService(reg), rpc.WithRegistryService(reg))

	// listening on specific port
	l, err := net.Listen("tcp", defaultAddr)
	if err != nil {
		return err
	}

	// listening on unix socket
	lsock, err := net.Listen("unix", path.Join(s.app.SocketDir, "lobby.sock"))
	if err != nil {
		return err
	}

	err = s.app.loadServerPlugins()
	if err != nil {
		return err
	}

	return s.app.runServers(map[net.Listener]lobby.Server{
		l:     srv,
		lsock: srv,
	}, func() error {
		return reg.Close()
	})
}<commit_msg>Using bolt as the default backend<commit_after>package cli

import (
	"net"
	"path"

	"github.com/asdine/lobby"
	"github.com/asdine/lobby/bolt"
	"github.com/asdine/lobby/rpc"
	cli "gopkg.in/urfave/cli.v1"
)

const (
	defaultAddr = ":5656"
)

func newRunCmd(a *app) cli.Command {
	cmd := runCmd{
		app: a,
	}

	return cli.Command{
		Name:   "run",
		Usage:  "Run Lobby",
		Action: cmd.run,
	}
}

type runCmd struct {
	app     *app
	mainSrv lobby.Server
}

func (s *runCmd) run(_ *cli.Context) error {
	return s.runMainServer()
}

func (s *runCmd) runMainServer() error {
	err := s.app.loadBackendPlugins()
	if err != nil {
		return err
	}

	dataPath := path.Join(s.app.DataDir, "bolt")
	registryPath := path.Join(dataPath, "registry.db")
	backendPath := path.Join(dataPath, "backend.db")

	err = initDir(dataPath)
	if err != nil {
		return err
	}

	// Creating default registry.
	reg, err := bolt.NewRegistry(registryPath)
	if err != nil {
		return err
	}

	// Creating default backend.
	bck, err := bolt.NewBackend(backendPath)
	if err != nil {
		return err
	}
	reg.RegisterBackend("bolt", bck)

	// Loading backends from plugins.
	for _, p := range s.app.Backends {
		bck, err := p.Backend()
		if err != nil {
			return err
		}

		reg.RegisterBackend(p.Name(), bck)
	}

	srv := rpc.NewServer(rpc.WithBucketService(reg), rpc.WithRegistryService(reg))

	// listening on specific port
	l, err := net.Listen("tcp", defaultAddr)
	if err != nil {
		return err
	}

	// listening on unix socket
	lsock, err := net.Listen("unix", path.Join(s.app.SocketDir, "lobby.sock"))
	if err != nil {
		return err
	}

	err = s.app.loadServerPlugins()
	if err != nil {
		return err
	}

	return s.app.runServers(map[net.Listener]lobby.Server{
		l:     srv,
		lsock: srv,
	}, func() error {
		err := bck.Close()
		if err != nil {
			return err
		}

		return reg.Close()
	})
}
{'fraction_non_alphanumeric': 0.1545994065281899, 'fraction_numerical': 0.002967359050445104, 'mean_word_length': 3.240251572327044, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6902327', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1350, 'n_words': 313}