Skip to content

Commit

Permalink
cmd: Split out separate Orchestrator scripts for with/without transco…
Browse files Browse the repository at this point in the history
…der and standardize how scripts are formatted
  • Loading branch information
thomshutt committed Mar 10, 2022
1 parent 85745b2 commit cbaf350
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ eth/protocol
/livepeer_router
/livepeer_bench

# Generated run scripts
run_*.sh

/.git.describe
/livepeer-windows-amd64.zip

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
### Bug Fixes 🐞

#### General
- \#2299 Prevent Transcoder/Broadcaster run scripts from using same CLI port
- \#2299 Split devtool Orchestrator run scripts into versions with/without external transcoder and prevent Transcoder/Broadcaster run scripts from using same CLI port (@thomshutt)

#### Broadcaster
- \#2296 Increase orchestrator discovery timeout from `500ms` to `1` (@leszko)
Expand Down
6 changes: 4 additions & 2 deletions cmd/devtool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ This command will submit the setup transactions for a broadcaster and generate t

`go run cmd/devtool/devtool.go setup transcoder`

This command will submit the setup transactions for an orchestrator/transcoder and generate the Bash scripts
`run_orchestrator_<ETH_ACCOUNT>.sh` which can be used to start an orchestrator node and `run_transcoder_<ETH_ACCOUNT>.sh` which can be used to start a transcoder node.
This command will submit the setup transactions for an orchestrator/transcoder and generate the Bash scripts:

* `run_orchestrator_with_transcoder_<ETH_ACCOUNT>.sh` which can be used to start an orchestrator node that contains a transcoder (combined OT)
* `run_orchestrator_standalone_<ETH_ACCOUNT>.sh` and `run_transcoder_<ETH_ACCOUNT>.sh` which can be used to start separate orchestrator and transcoder nodes (split O/T)
82 changes: 57 additions & 25 deletions cmd/devtool/devtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func main() {
}
serviceURI += strconv.Itoa(mediaPort + nodeIndex)
mediaPort += nodeIndex
cliPort += nodeIndex
cliPort += nodeIndex * 2 // Because we need different CLI ports for the Orchestrator and Transcoder scripts
rtmpPort += nodeIndex

t := getNodeType(isBroadcaster)
Expand Down Expand Up @@ -328,42 +328,74 @@ func ethSetup(ethAcctAddr, keystoreDir string, isBroadcaster bool) {
}

func createTranscoderRunScript(ethAcctAddr, dataDir, serviceHost string) {
script := "#!/bin/bash\n"
// script += fmt.Sprintf(`./livepeer -v 99 -datadir ./%s \
script += fmt.Sprintf(`./livepeer -v 99 -datadir ./%s -orchSecret secre -orchAddr %s:%d -cliAddr %s:%d -transcoder`,
dataDir, serviceHost, mediaPort, serviceHost, cliPort)
fName := fmt.Sprintf("run_transcoder_%s.sh", ethAcctAddr)
err := ioutil.WriteFile(fName, []byte(script), 0755)
if err != nil {
glog.Warningf("Error writing run script: %v", err)
args := []string{
"./livepeer",
"-v 99",
fmt.Sprintf("-datadir ./%s", dataDir),
"-orchSecret secre",
fmt.Sprintf("-orchAddr %s:%d", serviceHost, mediaPort),
fmt.Sprintf("-cliAddr %s:%d", serviceHost, cliPort),
"-transcoder",
}
fName := fmt.Sprintf("run_transcoder_%s.sh", ethAcctAddr)
writeScript(fName, args...)
}

func createRunScript(ethAcctAddr, dataDir, serviceHost string, isBroadcaster bool) {
script := "#!/bin/bash\n"
script += fmt.Sprintf(`./livepeer -v 99 -ethController %s -datadir ./%s \
-ethAcctAddr %s \
-ethUrl %s \
-ethPassword "" \
-network=devenv \
-blockPollingInterval 1 \
-monitor=false -currentManifest=true -cliAddr %s:%d -httpAddr %s:%d `,
ethController, dataDir, ethAcctAddr, endpoint, serviceHost, cliPort, serviceHost, mediaPort)
args := []string{
"./livepeer",
"-v 99",
"-ethController " + ethController,
"-datadir ./" + dataDir,
"-ethAcctAddr " + ethAcctAddr,
"-ethUrl " + endpoint,
"-ethPassword \"\"",
"-network=devenv",
"-blockPollingInterval 1",
"-monitor=false",
"-currentManifest=true",
fmt.Sprintf("-cliAddr %s:%d", serviceHost, cliPort),
fmt.Sprintf("-httpAddr %s:%d", serviceHost, mediaPort),
}

if !isBroadcaster {
script += fmt.Sprintf(` -initializeRound=true \
-serviceAddr %s:%d -transcoder=true -orchestrator=true \
-orchSecret secre -pricePerUnit 1
`, serviceHost, mediaPort)
args = append(
args,
"-initializeRound=true",
fmt.Sprintf("-serviceAddr=%s:%d", serviceHost, mediaPort),
"-orchestrator=true",
"-orchSecret secre",
"-pricePerUnit 1",
)

fName := fmt.Sprintf("run_%s_standalone_%s.sh", getNodeType(isBroadcaster), ethAcctAddr)
writeScript(fName, args...)

args = append(args, "-transcoder=true")
fName = fmt.Sprintf("run_%s_with_transcoder_%s.sh", getNodeType(isBroadcaster), ethAcctAddr)
writeScript(fName, args...)
} else {
script += fmt.Sprintf(` -broadcaster=true -rtmpAddr %s:%d`, serviceHost, rtmpPort)
args = append(
args,
"-broadcaster=true",
fmt.Sprintf("-rtmpAddr %s:%d", serviceHost, rtmpPort),
)

fName := fmt.Sprintf("run_%s_%s.sh", getNodeType(isBroadcaster), ethAcctAddr)
writeScript(fName, args...)
}
}

func writeScript(fName string, args ...string) {
script := "#!/bin/bash\n"

script += strings.Join(args, " \\\n\t")
script += "\n"

glog.Info(script)
fName := fmt.Sprintf("run_%s_%s.sh", getNodeType(isBroadcaster), ethAcctAddr)
err := ioutil.WriteFile(fName, []byte(script), 0755)
if err != nil {
glog.Warningf("Error writing run script: %v", err)
glog.Warningf("Error writing run script %q: %v", fName, err)
}
}

Expand Down

0 comments on commit cbaf350

Please sign in to comment.