Skip to content

Commit

Permalink
Check if app exists before polling
Browse files Browse the repository at this point in the history
  • Loading branch information
rugwirobaker committed Oct 6, 2021
1 parent 1f04379 commit 2b76b4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func runLogs(cc *cmdctx.CmdContext) error {
terminal.Debugf("could not connect to wireguard tunnel, err: %v\n", err)
terminal.Debug("Falling back to log polling...")

stream, err = logs.NewPollingStream(client)
stream, err = logs.NewPollingStream(client, opts)
if err != nil {
return err
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/logs/polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/jpillora/backoff"
"github.com/pkg/errors"
"github.com/superfly/flyctl/api"
)

Expand All @@ -13,7 +14,11 @@ type pollingStream struct {
apiClient *api.Client
}

func NewPollingStream(client *api.Client) (LogStream, error) {
func NewPollingStream(client *api.Client, opts *LogOptions) (LogStream, error) {
_, err := client.GetApp(opts.AppName)
if err != nil {
return nil, errors.Wrap(err, "err polling logs")
}
return &pollingStream{apiClient: client}, nil
}

Expand Down

0 comments on commit 2b76b4f

Please sign in to comment.