Skip to content

Commit

Permalink
Embed teststreamer into orchtester
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko committed Jun 3, 2022
1 parent 312710e commit f40ba6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion cmd/orch-tester/orch_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ import (
"errors"
"flag"
"fmt"
"github.com/livepeer/stream-tester/internal/server"
"io/ioutil"
"log"
"math"
"math/rand"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"

"github.com/golang/glog"
apiModels "github.com/livepeer/leaderboard-serverless/models"
"github.com/livepeer/m3u8"
streamtesterMetrics "github.com/livepeer/stream-tester/internal/metrics"
"github.com/livepeer/stream-tester/internal/testers"
"github.com/livepeer/stream-tester/model"
streamerModel "github.com/livepeer/stream-tester/model"
Expand All @@ -33,6 +36,8 @@ import (

const defaultHost = "127.0.0.1"
const streamTesterPort = "7934"
const streamTesterLapiToken = ""
const streamTesterMistCreds = ""
const prometheusPort = "9090"
const bcastMediaPort = "8935"
const bcastRTMPPort = "1935"
Expand All @@ -45,7 +50,7 @@ var start time.Time
func main() {
flag.Set("logtostderr", "true")
region := flag.String("region", "", "Region this service is operating in")
streamTester := flag.String("streamtester", "127.0.0.1"+":"+streamTesterPort, "Address for stream-tester server instance")
streamTester := flag.String("streamtester", "", "Address for stream-tester server instance")
broadcaster := flag.String("broadcaster", "127.0.0.1", "Broadcaster address")
metrics := flag.String("metrics", "127.0.0.1"+":"+prometheusPort, "Broadcaster metrics port")
media := flag.String("media", bcastMediaPort, "Broadcaster HTTP port")
Expand All @@ -71,6 +76,20 @@ func main() {
log.Fatal("region is required")
}

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

if *streamTester == "" {
glog.Info("Starting embedded streamtester service")
hostName, _ := os.Hostname()
streamtesterMetrics.InitCensus(hostName, model.Version, "streamtester")
s := server.NewStreamerServer(false, streamTesterLapiToken, streamTesterMistCreds, 4242)
go func() {
addr := fmt.Sprintf("%s:%s", "0.0.0.0", streamTesterPort)
s.StartWebServer(ctx, addr)
}()
}

metricsURL := defaultAddr(*metrics, defaultHost, prometheusPort)
streamTesterURL := defaultAddr(*streamTester, defaultHost, streamTesterPort)
leaderboardURL := defaultAddr(*leaderboard, defaultHost, "3001")
Expand Down
2 changes: 1 addition & 1 deletion internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (ss *StreamerServer) StartWebServer(ctx context.Context, bindAddr string) {
go func() {
<-ctx.Done()
c, _ := context.WithTimeout(context.Background(), time.Second)
glog.Infof("Shuttind down web server")
glog.Infof("Shutting down web server")
srv.Shutdown(c)
}()

Expand Down

0 comments on commit f40ba6f

Please sign in to comment.