Rewrite console throttling logic; drop complex timer usage and use a very simple throttle

This also removes server process termination logic when a server is breaching the output limits. It simply continues to efficiently throttle the console output.
This commit is contained in:
Dane Everitt
2022-01-30 19:31:04 -05:00
parent fb73d5dbbf
commit 2b2b5200eb
12 changed files with 482 additions and 386 deletions

View File

@@ -30,9 +30,8 @@ type Server struct {
ctx context.Context
ctxCancel *context.CancelFunc
emitterLock sync.Mutex
powerLock *powerLocker
throttleOnce sync.Once
emitterLock sync.Mutex
powerLock *system.Locker
// Maintains the configuration for the server. This is the data that gets returned by the Panel
// such as build settings and container images.
@@ -64,7 +63,8 @@ type Server struct {
restoring *system.AtomicBool
// The console throttler instance used to control outputs.
throttler *ConsoleThrottler
throttler *ConsoleThrottle
throttleOnce sync.Once
// Tracks open websocket connections for the server.
wsBag *WebsocketBag
@@ -87,7 +87,7 @@ func New(client remote.Client) (*Server, error) {
installing: system.NewAtomicBool(false),
transferring: system.NewAtomicBool(false),
restoring: system.NewAtomicBool(false),
powerLock: newPowerLocker(),
powerLock: system.NewLocker(),
sinks: map[SinkName]*sinkPool{
LogSink: newSinkPool(),
InstallSink: newSinkPool(),