blob: 578ab3c49975b0b40dd639be86099a164e846b17 [file] [log] [blame]
Jungho Ahn48d43072015-02-23 18:50:27 -08001// A simple command-line tool to run the benchmark server.
2package main
3
4import (
5 "flag"
6 "runtime"
7 "time"
8
9 "v.io/v23"
Jiri Simsa337af232015-02-27 14:36:46 -080010 "v.io/x/lib/vlog"
Jungho Ahn48d43072015-02-23 18:50:27 -080011
Jiri Simsaffceefa2015-02-28 11:03:34 -080012 "v.io/x/ref/lib/signals"
Matt Rosencrantz94502cf2015-03-18 09:43:44 -070013 "v.io/x/ref/profiles/internal/rpc/stress/internal"
Jiri Simsaffceefa2015-02-28 11:03:34 -080014 _ "v.io/x/ref/profiles/static"
Jungho Ahn48d43072015-02-23 18:50:27 -080015)
16
17var (
18 duration = flag.Duration("duration", 0, "duration of the stress test to run; if zero, there is no limit.")
19)
20
21func main() {
22 runtime.GOMAXPROCS(runtime.NumCPU())
23
24 ctx, shutdown := v23.Init()
25 defer shutdown()
26
27 server, ep, stop := internal.StartServer(ctx, v23.GetListenSpec(ctx))
28 vlog.Infof("listening on %s", ep.Name())
29
30 var timeout <-chan time.Time
31 if *duration > 0 {
32 timeout = time.After(*duration)
33 }
34 select {
35 case <-timeout:
36 case <-stop:
37 case <-signals.ShutdownOnSignals(ctx):
38 }
39
40 if err := server.Stop(); err != nil {
41 vlog.Fatalf("Stop() failed: %v", err)
42 }
43 vlog.Info("stopped.")
44}