Ejemplo n.º 1
0
func proxyServer() {
	loadConfigOrDie()
	debug.SetGCPercent(config.GCPercent)

	db, err := kvl.Open(config.Proxy.Database.Type, config.Proxy.Database.DSN)
	if err != nil {
		log.Fatalf("Couldn't connect to %v database: %v",
			config.Proxy.Database.Type, err)
	}
	defer db.Close()

	var h http.Handler
	h, err = proxyserver.New(db, config.Proxy.Scrubbers, config.Proxy.CacheSize)
	if err != nil {
		log.Fatalf("Couldn't initialize handler: %v", err)
	}

	h = httputil.NewLimitParallelism(config.Proxy.ParallelRequests, h)

	h = httputil.AddDebugHandlers(h, config.Proxy.Debug)

	if !config.Proxy.DisableHTTPLogging {
		h = httputil.LogHTTPRequests(h)
	}

	if config.Proxy.Listen == "none" {
		for {
			time.Sleep(time.Hour)
		}
	} else {
		serveOrDie(config.Proxy.Listen, h)
	}
}
Ejemplo n.º 2
0
func dbReindex() {
	loadConfigOrDie()
	debug.SetGCPercent(config.GCPercent)

	db, err := kvl.Open(config.Proxy.Database.Type, config.Proxy.Database.DSN)
	if err != nil {
		log.Fatalf("Couldn't connect to %v database: %v",
			config.Proxy.Database.Type, err)
	}
	defer db.Close()

	err = meta.Reindex(db) // does its own logging
	if err != nil {
		os.Exit(1)
	}
}