Improve update mechanism

This commit is contained in:
TenderIronh
2022-01-04 15:34:29 +08:00
parent 16b937ebd7
commit 7686af39e0
6 changed files with 62 additions and 45 deletions
+9 -5
View File
@@ -9,6 +9,8 @@ import (
var gConf Config
const IntValueNotSet int = -99999999
type AppConfig struct {
// required
AppName string
@@ -31,11 +33,11 @@ type AppConfig struct {
// TODO: add loglevel, maxlogfilesize
type Config struct {
Network NetworkConfig `json:"network"`
Apps []AppConfig `json:"apps"`
daemonMode bool
logLevel int
mtx sync.Mutex
Network NetworkConfig `json:"network"`
Apps []AppConfig `json:"apps"`
LogLevel int
mtx sync.Mutex
}
func (c *Config) add(app AppConfig) {
@@ -78,6 +80,8 @@ func (c *Config) save() {
func (c *Config) load() error {
c.mtx.Lock()
c.LogLevel = IntValueNotSet
c.Network.ShareBandwidth = IntValueNotSet
defer c.mtx.Unlock()
data, err := ioutil.ReadFile("config.json")
if err != nil {