diff --git a/config/config.go b/config/config.go index d2e2992..6d3705b 100644 --- a/config/config.go +++ b/config/config.go @@ -47,12 +47,6 @@ type Configuration struct { System SystemConfiguration `json:"system" yaml:"system"` Docker DockerConfiguration `json:"docker" yaml:"docker"` - // The amount of time in seconds that should elapse between disk usage checks - // run by the daemon. Setting a higher number can result in better IO performance - // at an increased risk of a malicious user creating a process that goes over - // the assigned disk limits. - DiskCheckTimeout int `yaml:"disk_check_timeout"` - // Defines internal throttling configurations for server processes to prevent // someone from running an endless loop that spams data to logs. Throttles ConsoleThrottles diff --git a/config/config_system.go b/config/config_system.go index 9176403..33b13ac 100644 --- a/config/config_system.go +++ b/config/config_system.go @@ -53,6 +53,10 @@ type SystemConfiguration struct { // considered stale and a re-check should occur. DANGER: setting this value too low can seriously // impact system performance and cause massive I/O bottlenecks and high CPU usage for the Wings // process. + // + // Set to 0 to disable disk checking entirely. This will always return 0 for the disk space used + // by a server and should only be set in extreme scenarios where performance is critical and + // disk usage is not a concern. DiskCheckInterval int64 `default:"150" yaml:"disk_check_interval"` // Determines if Wings should detect a server that stops with a normal exit code of diff --git a/server/filesystem/disk_space.go b/server/filesystem/disk_space.go index 2f233d7..1762fe4 100644 --- a/server/filesystem/disk_space.go +++ b/server/filesystem/disk_space.go @@ -97,6 +97,11 @@ func (fs *Filesystem) CachedUsage() int64 { // This is primarily to avoid a bunch of I/O operations from piling up on the server, especially on servers // with a large amount of files. func (fs *Filesystem) DiskUsage(allowStaleValue bool) (int64, error) { + // A disk check interval of 0 means this functionality is completely disabled. + if fs.diskCheckInterval == 0 { + return 0, nil + } + if !fs.lastLookupTime.Get().After(time.Now().Add(time.Second * fs.diskCheckInterval * -1)) { // If we are now allowing a stale response go ahead and perform the lookup and return the fresh // value. This is a blocking operation to the calling process.