Esempio n. 1
0
func setupGitFsTest(t *testing.T) (*GitFs, func()) {
	dir, err := ioutil.TempDir("", "gitfs-test")
	assert.Nil(t, err)

	cmd := exec.Command("tar", "xvf", "pages.tar.gz", "-C", dir)
	err = cmd.Run()
	assert.Nil(t, err)

	fsConfig := &config.Fuse{GitRepoDir: dir, Debug: false}
	logConfig := &config.Log{Local: "STDERR", Level: "WARN"}
	logger, err := log_driver.New(logConfig)
	assert.Nil(t, err)
	gitfs, err := New(fsConfig, logger)
	assert.Nil(t, err)
	go gitfs.Start()
	gitfs.WaitStart()
	return gitfs, func() {
		err := gitfs.Unmount()
		assert.Nil(t, err)
		err = os.RemoveAll(dir)
		assert.Nil(t, err)
	}
}
Esempio n. 2
0
File: main.go Progetto: bachue/pages
func main() {
	// TODO: Usage
	err := config.Load()
	if err != nil {
		log.Fatalf("Failed to load config: %s", err)
	}
	logger, err := log_driver.New(&config.Current.Log)
	if err != nil {
		log.Fatalf("Failed to create logger: %s", err)
	}

	var waitgroup sync.WaitGroup
	waitgroup.Add(2)

	go func() {
		sshdServer, err := sshd.NewServer(&config.Current.Sshd, logger)
		if err != nil {
			logger.Fatalf("Failed to create SSHD server: %s", err)
		}
		err = sshdServer.Start()
		if err != nil {
			logger.Fatalf("Failed to start SSHD server: %s", err)
		}
		waitgroup.Done()
	}()

	go func() {
		gitfs, err := gitfuse.New(&config.Current.Fuse, logger)
		if err != nil {
			logger.Fatalf("Failed to start GitFS: %s", err)
		}
		gitfs.Start()
		waitgroup.Done()
	}()

	waitgroup.Wait()
}