summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhrdtime
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-07-16 22:17:43 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-07-16 22:17:43 (GMT)
commita17956bde502c6629732b4710553fb3a968ec700 (patch)
treec58c215f1bcf384f66410ffa403ce0c13967db00 /src/helsinki.at/rhrdtime
parent7d801dc90d02a70d6d70f541bdfe20901bbe673b (diff)
added command line option for update interval
Diffstat (limited to 'src/helsinki.at/rhrdtime')
-rw-r--r--src/helsinki.at/rhrdtime/rhrdtime.go18
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()