Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SkipReadinessCheck flag #94

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading