diff options
Diffstat (limited to 'src/helsinki.at/rhrdtime')
-rw-r--r-- | src/helsinki.at/rhrdtime/rhrdtime.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/helsinki.at/rhrdtime/rhrdtime.go b/src/helsinki.at/rhrdtime/rhrdtime.go index 1a93f67..c90c699 100644 --- a/src/helsinki.at/rhrdtime/rhrdtime.go +++ b/src/helsinki.at/rhrdtime/rhrdtime.go @@ -28,6 +28,7 @@ import ( "fmt" "net/http" "time" + "flag" "github.com/codegangsta/martini" "github.com/gorilla/websocket" @@ -65,9 +66,24 @@ func RunMartini(ps *pubsub.PubSub) { } func main() { + interval_s := flag.String("interval", "15s", "the interval between updates, default 15s") + help := flag.Bool("help", false, "show usage") + + flag.Parse() + if *help { + flag.Usage() + return + } + + interval, err := time.ParseDuration(*interval_s) + if err != nil { + fmt.Println(err) + return + } + ps := pubsub.New(1) - ticker := time.NewTicker(time.Second * 1) + ticker := time.NewTicker(interval) go func() { for t := range ticker.C { tj, err := t.MarshalJSON() |