Skip to content

Commit e73751d

Browse files
rMaxiQpAgnesToulet
andauthored
Update internal/cmd/run.go
Co-authored-by: Agnès Toulet <[email protected]>
1 parent bf55577 commit e73751d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

internal/cmd/run.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,19 @@ func (c *cmdRun) serve(cmd *cobra.Command, srv *http.Server, shutdown func()) fu
8282
logger.WithError(err).Error("Error from API server")
8383
c.gs.OSExit(int(exitcodes.CannotStartRESTAPI))
8484
}
85-
} else {
86-
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
87-
// Only exit k6 if the user has explicitly set the REST API address
88-
if cmd.Flags().Lookup("address").Changed {
89-
logger.WithError(err).Error("Error from API server")
90-
c.gs.OSExit(int(exitcodes.CannotStartRESTAPI))
91-
} else {
92-
logger.WithError(err).Warn("Error from API server")
93-
}
85+
return
86+
}
87+
88+
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
89+
// Only exit k6 if the user has explicitly set the REST API address
90+
if cmd.Flags().Lookup("address").Changed {
91+
logger.WithError(err).Error("Error from API server")
92+
c.gs.OSExit(int(exitcodes.CannotStartRESTAPI))
93+
} else {
94+
logger.WithError(err).Warn("Error from API server")
9495
}
9596
}
97+
}
9698
}()
9799

98100
go func() {

0 commit comments

Comments
 (0)