Make disk checking timeout configurable
This commit is contained in:
		
							parent
							
								
									8f6494b092
								
							
						
					
					
						commit
						57221bdd30
					
				| 
						 | 
					@ -36,6 +36,12 @@ type SystemConfiguration struct {
 | 
				
			||||||
		Gid int
 | 
							Gid int
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// The amount of time in seconds that can elapse before a server's disk space calculation is
 | 
				
			||||||
 | 
						// 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.
 | 
				
			||||||
 | 
						DiskCheckInterval int64 `default:"150" yaml:"disk_check_interval"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Determines if Wings should detect a server that stops with a normal exit code of
 | 
						// Determines if Wings should detect a server that stops with a normal exit code of
 | 
				
			||||||
	// "0" as being crashed if the process stopped without any Wings interaction. E.g.
 | 
						// "0" as being crashed if the process stopped without any Wings interaction. E.g.
 | 
				
			||||||
	// the user did not press the stop button, but the process stopped cleanly.
 | 
						// the user did not press the stop button, but the process stopped cleanly.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -257,7 +257,7 @@ func (fs *Filesystem) HasSpaceAvailable(allowStaleValue bool) bool {
 | 
				
			||||||
func (fs *Filesystem) DiskUsage(allowStaleValue bool) (int64, error) {
 | 
					func (fs *Filesystem) DiskUsage(allowStaleValue bool) (int64, error) {
 | 
				
			||||||
	// Check if cache is expired.
 | 
						// Check if cache is expired.
 | 
				
			||||||
	fs.lookupTimeMu.RLock()
 | 
						fs.lookupTimeMu.RLock()
 | 
				
			||||||
	isValidInCache := fs.lastLookupTime.After(time.Now().Add(time.Second * -10))
 | 
						isValidInCache := fs.lastLookupTime.After(time.Now().Add(time.Second * time.Duration(-1*config.Get().System.DiskCheckInterval)))
 | 
				
			||||||
	fs.lookupTimeMu.RUnlock()
 | 
						fs.lookupTimeMu.RUnlock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if !isValidInCache {
 | 
						if !isValidInCache {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user