Skip to content

Commit

Permalink
Fixed startup delay to happen much higher in the initialization timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
maoueh committed Jul 23, 2024
1 parent 761068e commit 65488a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v1.3.1

- Move startup delay handling much higher in the initialization so that it happens before anything else.

## v1.3.0

- Adding `--startup-delay` flag when staring a sink noop. This allows for easier debugging or maintenance on the state on disk.
Expand Down
13 changes: 7 additions & 6 deletions cmd/substreams-sink-noop/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ func run(cmd *cobra.Command, args []string) error {
cancelApp()
})

// The startup delay should be performed before any other initialization otherwise
// sometimes you cannot fix some errors that are happening in `sink.NewFromViper`.
if startUpDelay := sflags.MustGetDuration(cmd, "startup-delay"); startUpDelay > 0 {
zlog.Info("sleeping before starting", zap.Duration("duration", startUpDelay))
time.Sleep(startUpDelay)
}

endpoint := args[0]
manifestPath := args[1]
moduleName := args[2]
Expand All @@ -96,7 +103,6 @@ func run(cmd *cobra.Command, args []string) error {
sinker.outputDataHash = newDataHasher(outputInterval)
}

startUpDelay := sflags.MustGetDuration(cmd, "startup-delay")
apiListenAddr := sflags.MustGetString(cmd, "api-listen-addr")
cleanState := sflags.MustGetBool(cmd, "clean")
stateStorePath := sflags.MustGetString(cmd, "state-store")
Expand All @@ -111,11 +117,6 @@ func run(cmd *cobra.Command, args []string) error {
zap.String("manage_listen_addr", apiListenAddr),
)

if startUpDelay > 0 {
zlog.Info("sleeping before starting", zap.Duration("duration", startUpDelay))
time.Sleep(startUpDelay)
}

headTrackerClient, headTrackerConnClose, headTrackerCallOpts, headTrackerHeaders, err := client.NewSubstreamsClient(sinker.ClientConfig())
cli.NoError(err, "Unable to create head tracker client")
defer headTrackerConnClose()
Expand Down

0 comments on commit 65488a4

Please sign in to comment.