Skip to content

Commit

Permalink
Add SkipReadinessCheck flag
Browse files Browse the repository at this point in the history
  • Loading branch information
md5nake committed Sep 8, 2024
1 parent 6773a87 commit 7464095
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions java_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type statusCmd struct {
UseProxy bool `usage:"supports contacting Bungeecord when proxy_protocol enabled"`
ProxyVersion byte `usage:"version of PROXY protocol to use" default:"1"`

SkipReadinessCheck bool `usage:"returns success when pinging a server without player info, or with a max player count of 0"`

ShowPlayerCount bool `usage:"show just the online player count"`
}

Expand Down Expand Up @@ -90,7 +92,7 @@ func (c *statusCmd) Execute(_ context.Context, _ *flag.FlagSet, args ...interfac
// While server is starting up it will answer pings, but respond with empty JSON object.
// As such, we'll sanity check the max players value to see if a zero-value has been
// provided for info.
if info.Players.Max == 0 {
if info.Players.Max == 0 && !c.SkipReadinessCheck {

_, _ = fmt.Fprintf(os.Stderr, "server not ready %s:%d", c.Host, c.Port)
return errors.New("server not ready")
Expand Down Expand Up @@ -127,7 +129,7 @@ func (c *statusCmd) ExecuteServerListPing() subcommands.ExitStatus {
return err
}

if response.MaxPlayers == "0" {
if response.MaxPlayers == "0" && !c.SkipReadinessCheck {
return errors.New("server not ready")
}

Expand Down Expand Up @@ -176,7 +178,7 @@ func (c *statusCmd) ExecuteMcUtilPing(logger *zap.Logger) subcommands.ExitStatus
response := hs.Properties.Infos()
logger.Debug("mcutils ping returned", zap.Any("properties", response))

if response.Players.Max == 0 {
if response.Players.Max == 0 && !c.SkipReadinessCheck {
return errors.New("server not ready")
}

Expand Down

0 comments on commit 7464095

Please sign in to comment.