fix: concurrency protect configuing
continuous-integration/drone/tag Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
parent
f76cc2f75e
commit
8b85b8e89b
10
configui.go
10
configui.go
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"html/template"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"kumoly.io/lib/klog"
|
||||
|
@ -17,7 +18,7 @@ import (
|
|||
var UNIX_SHELL = "sh"
|
||||
var WIN_SHELL = "cmd"
|
||||
|
||||
const version = "v0.1.3"
|
||||
const version = "v0.1.8"
|
||||
|
||||
//go:embed templates
|
||||
var tmplFS embed.FS
|
||||
|
@ -58,6 +59,7 @@ type ConfigUI struct {
|
|||
log *klog.Logger `json:"-"`
|
||||
ksrv_log *klog.Logger `json:"-"`
|
||||
f *os.File `json:"-"`
|
||||
configLock sync.Mutex `json:"-"`
|
||||
}
|
||||
|
||||
func New() *ConfigUI {
|
||||
|
@ -119,6 +121,8 @@ func (cui *ConfigUI) LoadConfig(confstr string) error {
|
|||
}
|
||||
|
||||
// copy
|
||||
cui.configLock.Lock()
|
||||
defer cui.configLock.Unlock()
|
||||
cui.fileIndex = tmpIndex
|
||||
cui.Files = tmpConf.Files
|
||||
cui.AllowIP = tmpConf.AllowIP
|
||||
|
@ -127,6 +131,7 @@ func (cui *ConfigUI) LoadConfig(confstr string) error {
|
|||
cui.ConfigPath = tmpConf.ConfigPath
|
||||
cui.HideConfig = tmpConf.HideConfig
|
||||
cui.NoReconfig = tmpConf.NoReconfig
|
||||
cui.ResultBellow = tmpConf.ResultBellow
|
||||
|
||||
cui.AppName = tmpConf.AppName
|
||||
if cui.AppName == "" {
|
||||
|
@ -149,9 +154,6 @@ func (cui *ConfigUI) LoadConfig(confstr string) error {
|
|||
|
||||
cui.log = klog.Sub(cui.AppName)
|
||||
|
||||
// NOT implemented
|
||||
cui.ResultBellow = tmpConf.ResultBellow
|
||||
|
||||
cui.LogLevel = tmpConf.LogLevel
|
||||
if cui.LogLevel == 0 {
|
||||
cui.LogLevel = klog.Lerror | klog.Linfo
|
||||
|
|
Loading…
Reference in New Issue