From 7dde122d9b291d790f23c1bb3b64c5db0d7b07e3 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 25 Mar 2017 15:55:48 +1300 Subject: [PATCH] webcmd: MaxHistoryLines --- Task.go | 3 +++ cmd/webcmd/webcmd.conf | 2 ++ config.go | 7 ++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Task.go b/Task.go index 30786cc..4adddab 100644 --- a/Task.go +++ b/Task.go @@ -85,6 +85,9 @@ func (this *App) LaunchTask(params []string) (taskRef string, err error) { task := this.tasks[ref] task.output = append(task.output, OutputLine{isError: isError, text: text}) + if len(task.output) > 2*this.cfg.MaxHistoryLines { + task.output = task.output[this.cfg.MaxHistoryLines:] + } this.tasks[ref] = task } diff --git a/cmd/webcmd/webcmd.conf b/cmd/webcmd/webcmd.conf index 7a6927a..a6459f2 100644 --- a/cmd/webcmd/webcmd.conf +++ b/cmd/webcmd/webcmd.conf @@ -3,6 +3,8 @@ "ListenAddress": ":8192", + "MaxHistoryLines": 100, + "Commands": [ { diff --git a/config.go b/config.go index 85cbf8a..14fd4a2 100644 --- a/config.go +++ b/config.go @@ -27,7 +27,8 @@ type CommandConfig struct { } type AppConfig struct { - ListenAddress string - AppTitle string - Commands []CommandConfig + ListenAddress string + AppTitle string + MaxHistoryLines int // default zero: unlimited history for each command + Commands []CommandConfig }