Exemplo n.º 1
0
func init() {
	blobserver.RegisterStorageConstructor("appengine", blobserver.StorageConstructor(newFromConfig))

	config, err := serverconfig.Load("./config.json")
	if err != nil {
		exitFailure("Could not load server config: %v", err)
	}

	baseURL := ""
	err = config.InstallHandlers(mux, baseURL)
	if err != nil {
		exitFailure("Error parsing config: %v", err)
	}
}
Exemplo n.º 2
0
func main() {
	flag.Parse()

	file := *flagConfigFile
	if !filepath.IsAbs(file) {
		file = filepath.Join(osutil.CamliConfigDir(), file)
	}
	config, err := serverconfig.Load(file)
	if err != nil {
		exitFailure("Could not load server config: %v", err)
	}

	ws := webserver.New()
	baseURL := ws.BaseURL()

	{
		cert, key := config.OptionalString("TLSCertFile", ""), config.OptionalString("TLSKeyFile", "")
		if (cert != "") != (key != "") {
			exitFailure("TLSCertFile and TLSKeyFile must both be either present or absent")
		}
		if cert != "" {
			ws.SetTLS(cert, key)
		}
	}

	err = config.InstallHandlers(ws, baseURL)
	if err != nil {
		exitFailure("Error parsing config: %v", err)
	}

	ws.Listen()

	if config.UIPath != "" {
		uiURL := ws.BaseURL() + config.UIPath
		log.Printf("UI available at %s", uiURL)
		if runtime.GOOS == "windows" {
			// Might be double-clicking an icon with no shell window?
			// Just open the URL for them.
			osutil.OpenURL(uiURL)
		}
	}
	ws.Serve()
}