Skip to content
Merged
Show file tree
Hide file tree
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
30 changes: 25 additions & 5 deletions .web/docs/guide/config/reload.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Gate Auto Config Reload - Live Configuration Updates"
description: "Learn about Gate automatic config reloading feature. Update server settings without restarting or disconnecting players."
title: 'Gate Auto Config Reload - Live Configuration Updates'
description: 'Learn about Gate automatic config reloading feature. Update server settings without restarting or disconnecting players.'
---

# Auto Config Reload
Expand Down Expand Up @@ -41,6 +41,26 @@ This feature is always enabled by default, given that you have a config file.

## How to disable it

Please note that the auto config reload feature cannot be disabled.
If you feel a compelling need to do so, please don't hesitate to [open an issue](https://github.com/minekube/gate/issues/new?title=Disable%20auto%20config%20reload&body=I%20want%20to%20disable%20auto%20config%20reload%20because%20...)
on our GitHub repository.
You can disable auto config reload in several ways:

### Command line flag

```bash
gate --no-auto-reload
```

### Environment variable

```bash
GATE_NO_AUTO_RELOAD=true gate
```

### Config file

Add to your `config.yml`:

```yaml
noAutoReload: true
```

This is useful in environments where file watching is not available or causes permission issues (e.g., NixOS with sops-nix).
27 changes: 19 additions & 8 deletions cmd/gate/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ func App() *cli.App {
Visit the website https://gate.minekube.com/ for more information.`

var (
debug bool
configFile string
verbosity int
showVersion bool
debug bool
configFile string
verbosity int
showVersion bool
noAutoReload bool
)
app.Flags = []cli.Flag{
&cli.StringFlag{
Expand Down Expand Up @@ -83,6 +84,12 @@ Visit the website https://gate.minekube.com/ for more information.`
Usage: "Show version information",
Destination: &showVersion,
},
&cli.BoolFlag{
Name: "no-auto-reload",
Usage: "Disable automatic config file reloading",
Destination: &noAutoReload,
EnvVars: []string{"GATE_NO_AUTO_RELOAD"},
},
}

app.Action = func(c *cli.Context) error {
Expand Down Expand Up @@ -134,11 +141,15 @@ Visit the website https://gate.minekube.com/ for more information.`
log.Info("logging verbosity", "verbosity", verbosity)
log.Info("using config file", "config", v.ConfigFileUsed())

// Check if auto reload is disabled (via flag, env var, or config)
disableAutoReload := noAutoReload || cfg.NoAutoReload

// Start Gate
if err = gate.Start(c.Context,
gate.WithConfig(*cfg),
gate.WithAutoConfigReload(v.ConfigFileUsed()),
); err != nil {
startOpts := []gate.StartOption{gate.WithConfig(*cfg)}
if !disableAutoReload && v.ConfigFileUsed() != "" {
startOpts = append(startOpts, gate.WithAutoConfigReload(v.ConfigFileUsed()))
}
if err = gate.Start(c.Context, startOpts...); err != nil {
return cli.Exit(fmt.Errorf("error running Gate: %w", err), 1)
}
return nil
Expand Down
3 changes: 3 additions & 0 deletions pkg/gate/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type Config struct {
Connect connect.Config `json:"connect,omitempty" yaml:"connect,omitempty"`
// See API struct.
API API `json:"api,omitempty" yaml:"api,omitempty"`
// NoAutoReload disables automatic config file reloading.
// This is useful in environments where file watching causes issues.
NoAutoReload bool `json:"noAutoReload,omitempty" yaml:"noAutoReload,omitempty"`
}

// HealthService is a GRPC health probe service for use with Kubernetes pods.
Expand Down