func main() { flag.Parse() storage := memory.New(*argSampleSize, *argHistoryDuration) // TODO(monnand): Add stats writer for manager containerManager, err := manager.New(storage) if err != nil { log.Fatalf("Failed to create a Container Manager: %s", err) } if err := lmctfy.Register("/"); err != nil { log.Printf("lmctfy registration failed: %v.", err) log.Print("Running in docker only mode.") if err := docker.Register(containerManager, "/"); err != nil { log.Printf("Docker registration failed: %v.", err) log.Fatalf("Unable to continue without docker or lmctfy.") } } if err := docker.Register(containerManager, "/docker"); err != nil { // Ignore this error because we should work with lmctfy only log.Printf("Docker registration failed: %v.", err) log.Print("Running in lmctfy only mode.") } // Handler for static content. http.HandleFunc(static.StaticResource, func(w http.ResponseWriter, r *http.Request) { err := static.HandleRequest(w, r.URL) if err != nil { fmt.Fprintf(w, "%s", err) } }) // Handler for the API. http.HandleFunc(api.ApiResource, func(w http.ResponseWriter, r *http.Request) { err := api.HandleRequest(containerManager, w, r.URL) if err != nil { fmt.Fprintf(w, "%s", err) } }) // Redirect / to containers page. http.Handle("/", http.RedirectHandler(pages.ContainersPage, http.StatusTemporaryRedirect)) // Register the handler for the containers page. http.HandleFunc(pages.ContainersPage, func(w http.ResponseWriter, r *http.Request) { err := pages.ServerContainersPage(containerManager, w, r.URL) if err != nil { fmt.Fprintf(w, "%s", err) } }) go containerManager.Start() log.Printf("Starting cAdvisor version: %q", info.VERSION) log.Print("About to serve on port ", *argPort) addr := fmt.Sprintf(":%v", *argPort) log.Fatal(http.ListenAndServe(addr, nil)) }
func main() { flag.Parse() storageDriver, err := NewStorageDriver(*argDbDriver) if err != nil { log.Fatalf("Failed to connect to database: %s", err) } containerManager, err := manager.New(storageDriver) if err != nil { log.Fatalf("Failed to create a Container Manager: %s", err) } // Register Docker. if err := docker.Register(containerManager); err != nil { log.Printf("Docker registration failed: %v.", err) } // Register the raw driver. if err := raw.Register(containerManager); err != nil { log.Fatalf("raw registration failed: %v.", err) } // Handler for static content. http.HandleFunc(static.StaticResource, func(w http.ResponseWriter, r *http.Request) { err := static.HandleRequest(w, r.URL) if err != nil { fmt.Fprintf(w, "%s", err) } }) // Handler for the API. http.HandleFunc(api.ApiResource, func(w http.ResponseWriter, r *http.Request) { err := api.HandleRequest(containerManager, w, r) if err != nil { fmt.Fprintf(w, "%s", err) } }) // Redirect / to containers page. http.Handle("/", http.RedirectHandler(pages.ContainersPage, http.StatusTemporaryRedirect)) // Register the handler for the containers page. http.HandleFunc(pages.ContainersPage, func(w http.ResponseWriter, r *http.Request) { err := pages.ServerContainersPage(containerManager, w, r.URL) if err != nil { fmt.Fprintf(w, "%s", err) } }) go func() { log.Fatal(containerManager.Start()) }() log.Printf("Starting cAdvisor version: %q", info.VERSION) log.Print("About to serve on port ", *argPort) addr := fmt.Sprintf(":%v", *argPort) log.Fatal(http.ListenAndServe(addr, nil)) }
func main() { flag.Parse() // XXX(dengnan): Should we allow users to specify which sampler they want to use? container.SetStatsParameter(&container.StatsParameter{ Sampler: "uniform", NumSamples: *argSampleSize, ResetPeriod: *argResetPeriod, }) containerManager, err := manager.New() if err != nil { log.Fatalf("Failed to create a Container Manager: %s", err) } if err := lmctfy.Register("/"); err != nil { log.Printf("lmctfy registration failed: %v.", err) log.Print("Running in docker only mode.") if err := docker.Register(containerManager, "/"); err != nil { log.Printf("Docker registration failed: %v.", err) log.Fatalf("Unable to continue without docker or lmctfy.") } } if err := docker.Register(containerManager, "/docker"); err != nil { // Ignore this error because we should work with lmctfy only log.Printf("Docker registration failed: %v.", err) log.Print("Running in lmctfy only mode.") } // Handler for static content. http.HandleFunc(static.StaticResource, func(w http.ResponseWriter, r *http.Request) { err := static.HandleRequest(w, r.URL) if err != nil { fmt.Fprintf(w, "%s", err) } }) // Handler for the API. http.HandleFunc(api.ApiResource, func(w http.ResponseWriter, r *http.Request) { err := api.HandleRequest(containerManager, w, r.URL) if err != nil { fmt.Fprintf(w, "%s", err) } }) // Redirect / to containers page. http.Handle("/", http.RedirectHandler(pages.ContainersPage, http.StatusTemporaryRedirect)) // Register the handler for the containers page. http.HandleFunc(pages.ContainersPage, func(w http.ResponseWriter, r *http.Request) { err := pages.ServerContainersPage(containerManager, w, r.URL) if err != nil { fmt.Fprintf(w, "%s", err) } }) go containerManager.Start() log.Print("About to serve on port ", *argPort) addr := fmt.Sprintf(":%v", *argPort) log.Fatal(http.ListenAndServe(addr, nil)) }
func main() { flag.Parse() storageDriver, err := NewStorageDriver(*argDbDriver) if err != nil { log.Fatalf("Failed to connect to database: %s", err) } containerManager, err := manager.New(storageDriver) if err != nil { log.Fatalf("Failed to create a Container Manager: %s", err) } // Register lmctfy for the root if allowed and available. registeredRoot := false if *argAllowLmctfy { if err := lmctfy.Register("/"); err != nil { log.Printf("lmctfy registration failed: %v.", err) log.Print("Running in docker only mode.") } else { registeredRoot = true } } // Register Docker for root if we were unable to register lmctfy. if !registeredRoot { if err := docker.Register(containerManager, "/"); err != nil { log.Printf("Docker registration failed: %v.", err) log.Fatalf("Unable to continue without root handler.") } } // Register Docker for all Docker containers. if err := docker.Register(containerManager, "/docker"); err != nil { // Ignore this error because we should work with lmctfy only log.Printf("Docker registration failed: %v.", err) log.Print("Running in lmctfy only mode.") } // Handler for static content. http.HandleFunc(static.StaticResource, func(w http.ResponseWriter, r *http.Request) { err := static.HandleRequest(w, r.URL) if err != nil { fmt.Fprintf(w, "%s", err) } }) // Handler for the API. http.HandleFunc(api.ApiResource, func(w http.ResponseWriter, r *http.Request) { err := api.HandleRequest(containerManager, w, r) if err != nil { fmt.Fprintf(w, "%s", err) } }) // Redirect / to containers page. http.Handle("/", http.RedirectHandler(pages.ContainersPage, http.StatusTemporaryRedirect)) // Register the handler for the containers page. http.HandleFunc(pages.ContainersPage, func(w http.ResponseWriter, r *http.Request) { err := pages.ServerContainersPage(containerManager, w, r.URL) if err != nil { fmt.Fprintf(w, "%s", err) } }) go containerManager.Start() log.Printf("Starting cAdvisor version: %q", info.VERSION) log.Print("About to serve on port ", *argPort) addr := fmt.Sprintf(":%v", *argPort) log.Fatal(http.ListenAndServe(addr, nil)) }