Skip to content

Commit

Permalink
Orchestrator: add flag to skip the availability check on startup (#2928)
Browse files Browse the repository at this point in the history
* Orchestrator: add flag to skip the availability check on startup

* Edit name of startup test param

* Mod pending changelog

---------

Co-authored-by: Thom Shutt <thomshutt@users.noreply.github.com>
  • Loading branch information
stronk-dev and thomshutt committed Dec 14, 2023
1 parent 37447ea commit 002e602
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#### Orchestrator

- #2911 Set default price with livepeer_cli option 20 (@eliteprox)
- #2928 Added `startupAvailabilityCheck` param to skip the availability check on startup (@stronk-dev)

#### Transcoder

Expand Down
3 changes: 3 additions & 0 deletions cmd/livepeer/livepeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ func parseLivepeerConfig() starter.LivepeerConfig {
cfg.AuthWebhookURL = flag.String("authWebhookUrl", *cfg.AuthWebhookURL, "RTMP authentication webhook URL")
cfg.DetectionWebhookURL = flag.String("detectionWebhookUrl", *cfg.DetectionWebhookURL, "(Experimental) Detection results callback URL")

// flags
cfg.TestOrchAvail = flag.Bool("startupAvailabilityCheck", *cfg.TestOrchAvail, "Set to false to disable the startup Orchestrator availability check on the configured serviceAddr")

return cfg
}

Expand Down
21 changes: 15 additions & 6 deletions cmd/livepeer/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ type LivepeerConfig struct {
OrchWebhookURL *string
DetectionWebhookURL *string
OrchBlacklist *string
TestOrchAvail *bool
}

// DefaultLivepeerConfig creates LivepeerConfig exactly the same as when no flags are passed to the livepeer process.
Expand Down Expand Up @@ -232,6 +233,9 @@ func DefaultLivepeerConfig() LivepeerConfig {
defaultOrchWebhookURL := ""
defaultDetectionWebhookURL := ""

// Flags
defaultTestOrchAvail := true

return LivepeerConfig{
// Network & Addresses:
Network: &defaultNetwork,
Expand Down Expand Up @@ -316,6 +320,9 @@ func DefaultLivepeerConfig() LivepeerConfig {
AuthWebhookURL: &defaultAuthWebhookURL,
OrchWebhookURL: &defaultOrchWebhookURL,
DetectionWebhookURL: &defaultDetectionWebhookURL,

// Flags
TestOrchAvail: &defaultTestOrchAvail,
}
}

Expand Down Expand Up @@ -1227,12 +1234,14 @@ func StartLivepeer(ctx context.Context, cfg LivepeerConfig) {
}()

// check whether or not the orchestrator is available
time.Sleep(2 * time.Second)
orchAvail := server.CheckOrchestratorAvailability(orch)
if !orchAvail {
// shut down orchestrator
glog.Infof("Orchestrator not available at %v; shutting down", orch.ServiceURI())
tc <- struct{}{}
if *cfg.TestOrchAvail {
time.Sleep(2 * time.Second)
orchAvail := server.CheckOrchestratorAvailability(orch)
if !orchAvail {
// shut down orchestrator
glog.Infof("Orchestrator not available at %v; shutting down", orch.ServiceURI())
tc <- struct{}{}
}
}

}()
Expand Down

0 comments on commit 002e602

Please sign in to comment.