From 4695555e178bcabe54c5bf82117c9c4cef5440b5 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Wed, 11 Oct 2017 00:24:02 +0200 Subject: Fixed Syncthing folder status events and exec command. --- lib/xdsconfig/config.go | 9 ++++++++- lib/xdsconfig/configfile.go | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'lib/xdsconfig') diff --git a/lib/xdsconfig/config.go b/lib/xdsconfig/config.go index 9cff862..9279a67 100644 --- a/lib/xdsconfig/config.go +++ b/lib/xdsconfig/config.go @@ -10,10 +10,12 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" common "github.com/iotbzh/xds-common/golib" + uuid "github.com/satori/go.uuid" ) // Config parameters (json format) of /config command type Config struct { + AgentUID string Version string APIVersion string VersionGitTag string @@ -43,8 +45,12 @@ func Init(ctx *cli.Context, log *logrus.Logger) (*Config, error) { defaultWebAppDir := "${EXEPATH}/www" defaultSTHomeDir := "${HOME}/.xds/agent/syncthing-config" + // TODO: allocate uuid only the first time and save+reuse it later + uuid := uuid.NewV1().String() + // Define default configuration c := Config{ + AgentUID: uuid, Version: ctx.App.Metadata["version"].(string), APIVersion: DefaultAPIVersion, VersionGitTag: ctx.App.Metadata["git-tag"].(string), @@ -59,7 +65,6 @@ func Init(ctx *cli.Context, log *logrus.Logger) (*Config, error) { HTTPPort: "8800", WebAppDir: defaultWebAppDir, LogsDir: "/tmp/logs", - // SEB XDSAPIKey: "1234abcezam", ServersConf: []XDSServerConf{ XDSServerConf{ URL: "http://localhost:8000", @@ -107,6 +112,8 @@ func Init(ctx *cli.Context, log *logrus.Logger) (*Config, error) { return nil, fmt.Errorf("Cannot create logs dir: %v", err) } } + + c.Log.Infoln("Agent UUID: ", uuid) c.Log.Infoln("Logs file: ", c.Options.LogFile) c.Log.Infoln("Logs directory: ", c.FileConf.LogsDir) diff --git a/lib/xdsconfig/configfile.go b/lib/xdsconfig/configfile.go index a47038b..6eaaf6a 100644 --- a/lib/xdsconfig/configfile.go +++ b/lib/xdsconfig/configfile.go @@ -26,10 +26,10 @@ type XDSServerConf struct { } type FileConfig struct { - HTTPPort string `json:"httpPort"` - WebAppDir string `json:"webAppDir"` - LogsDir string `json:"logsDir"` - // SEB A SUP ? XDSAPIKey string `json:"xds-apikey"` + HTTPPort string `json:"httpPort"` + WebAppDir string `json:"webAppDir"` + LogsDir string `json:"logsDir"` + XDSAPIKey string `json:"xds-apikey"` ServersConf []XDSServerConf `json:"xdsServers"` SThgConf *SyncThingConf `json:"syncthing"` } -- cgit 1.2.3-korg