aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xdsconfig/config.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-09-13 15:42:09 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-09-13 17:22:13 +0200
commit5756bd350d585660cce53a28dc66bfcf162ecca1 (patch)
treecbb0c3a013c70fd48365effe90b5bd95e03e4c44 /lib/xdsconfig/config.go
parent6849b490ccfe2f5ed2bb577758edf30445691378 (diff)
Set install dir to /opt/AGL and move conf to $HOME/.xds-server
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/xdsconfig/config.go')
-rw-r--r--lib/xdsconfig/config.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/xdsconfig/config.go b/lib/xdsconfig/config.go
index 82ca97f..53d1639 100644
--- a/lib/xdsconfig/config.go
+++ b/lib/xdsconfig/config.go
@@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
+ "path/filepath"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
@@ -62,6 +63,7 @@ func Init(cliCtx *cli.Context, log *logrus.Logger) (*Config, error) {
ShareRootDir: DefaultShareDir,
SdkRootDir: DefaultSdkRootDir,
HTTPPort: DefaultPort,
+ LogsDir: "",
},
Log: log,
}
@@ -80,11 +82,35 @@ func Init(cliCtx *cli.Context, log *logrus.Logger) (*Config, error) {
}
c.Log.Infoln("Share root directory: ", c.FileConf.ShareRootDir)
+ // Where Logs are redirected:
+ // default 'stdout' (logfile option default value)
+ // else use file (or filepath) set by --logfile option
+ // that may be overwritten by LogsDir field of config file
+ logF := c.Options.LogFile
+ logD := c.FileConf.LogsDir
+ if logF != "stdout" {
+ if logD != "" {
+ lf := filepath.Base(logF)
+ if lf == "" || lf == "." {
+ lf = "xds-server.log"
+ }
+ logF = filepath.Join(logD, lf)
+ } else {
+ logD = filepath.Dir(logF)
+ }
+ }
+ if logD == "" || logD == "." {
+ logD = "/tmp/xds/logs"
+ }
+ c.Options.LogFile = logF
+ c.FileConf.LogsDir = logD
+
if c.FileConf.LogsDir != "" && !common.Exists(c.FileConf.LogsDir) {
if err := os.MkdirAll(c.FileConf.LogsDir, 0770); err != nil {
return nil, fmt.Errorf("Cannot create logs dir: %v", err)
}
}
+ c.Log.Infoln("Logs file: ", c.Options.LogFile)
c.Log.Infoln("Logs directory: ", c.FileConf.LogsDir)
return &c, nil