Last active
April 12, 2018 11:59
-
-
Save nesv/9233955 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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