Skip to content
Snippets Groups Projects
Commit 120c87f6 authored by Kamil Kisiel's avatar Kamil Kisiel
Browse files

Added command-line options for configuring the server

parent e3d57fc8
No related branches found
No related tags found
No related merge requests found
package main
import (
"log"
"flag"
"fmt"
"github.com/kisielk/gostatsd/statsd"
"log"
"os"
)
var (
metricsAddr string
consoleAddr string
graphiteAddr string
)
func init() {
const (
defaultMetricsAddr = ":8125"
defaultConsoleAddr = ":8126"
defaultGraphiteAddr = ""
)
flag.StringVar(&metricsAddr, "l", defaultMetricsAddr, "Address on which to listen for metrics (optional)")
flag.StringVar(&consoleAddr, "c", defaultConsoleAddr, "Address on which to listen for console sessions (optional)")
flag.StringVar(&graphiteAddr, "g", defaultGraphiteAddr, "Address of the graphite server (required)")
}
func main() {
err := statsd.ListenAndServe(":8125", ":8126", "localhost:1234")
flag.Parse()
if graphiteAddr == "" {
fmt.Printf("Error: You must provide the address of the graphite server with the -g flag\n")
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
flag.PrintDefaults()
return
}
err := statsd.ListenAndServe(metricsAddr, consoleAddr, graphiteAddr)
if err != nil {
log.Fatal(err)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment