Skip to content

Instantly share code, notes, and snippets.

@nesv
Last active April 12, 2018 11:59
Show Gist options
  • Save nesv/9233955 to your computer and use it in GitHub Desktop.
Save nesv/9233955 to your computer and use it in GitHub Desktop.
package main
import (
"flag"
"fmt"
"net/http"
)
var (
NWorkers = flag.Int("n", 4, "The number of workers to start")
HTTPAddr = flag.String("http", "127.0.0.1:8000", "Address to listen for HTTP requests on")
)
func main() {
// Parse the command-line flags.
flag.Parse()
// Start the dispatcher.
fmt.Println("Starting the dispatcher")
StartDispatcher(*NWorkers)
// Register our collector as an HTTP handler function.
fmt.Println("Registering the collector")
http.HandleFunc("/work", Collector)
// Start the HTTP server!
fmt.Println("HTTP server listening on", *HTTPAddr)
if err := http.ListenAndServe(*HTTPAddr, nil); err != nil {
fmt.Println(err.Error())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment