diff --git a/README.md b/README.md index 5943ac8..a0fb347 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,12 @@ The server package relies on sqlite which in turn requires the use of CGO. As pe The app takes the following arguments - -debug: enabled debug logging - -exportServerBundle: Export the server bundle to a file called serverbundle - +- -disableMetrics: Disable metrics reporting to serverMonitor.txt and associated tracking routines +- -dir [directory]: specify a directory to store server files (default is current directory) The app takes the following environment variables - CWTCH_HOME: sets the config dir for the app +- DISABLE_METRICS: if set to any value ('1') it disables metrics reporting to serverMonitor.txt and associated tracking routines `env CONFIG_HOME=./conf ./app` @@ -38,4 +40,10 @@ or run our prebuild ones with `pull openpriv/cwtch-server` -and run it. It stores all Cwtch data in a Volume at `/var/lib/cwtch` +and run it. It stores all Cwtch data in a Volume at `/var/lib/cwtch` so if you want the server data to persist you would run + +`docker run openpriv/cwtch-server -v /var/lib/cwtch/server01:/var/lib/cwtch` + +to create a persistent container you might try a command like: + +`docker run openpriv/cwtch-server --name cwtch -v /var/lib/cwtch/server01:/var/lib/cwtch --restart always` diff --git a/app/main.go b/app/main.go index 3421a37..3082a45 100644 --- a/app/main.go +++ b/app/main.go @@ -21,6 +21,8 @@ import ( func main() { flagDebug := flag.Bool("debug", false, "Enable debug logging") flagExportServer := flag.Bool("exportServerBundle", false, "Export the server bundle to a file called serverbundle") + flagDir := flag.String("dir", ".", "Directory to store server files in (config, encrypted messages, metrics)") + flagDisableMetrics := flag.Bool("disableMetrics", false, "Disable metrics reporting") flag.Parse() log.AddEverythingFromPattern("server/app/main") @@ -32,6 +34,9 @@ func main() { log.SetLevel(log.LevelDebug) } configDir := os.Getenv("CWTCH_HOME") + if configDir == "" { + configDir = *flagDir + } if len(os.Args) == 2 && os.Args[1] == "gen1" { config := new(cwtchserver.Config) @@ -52,11 +57,16 @@ func main() { return } - serverConfig, err := cwtchserver.LoadCreateDefaultConfigFile(configDir, cwtchserver.ServerConfigFile, false, "", true) + disableMetrics := *flagDisableMetrics + if os.Getenv("DISABLE_METRICS") != "" { + disableMetrics = true + } + serverConfig, err := cwtchserver.LoadCreateDefaultConfigFile(configDir, cwtchserver.ServerConfigFile, false, "", !disableMetrics) if err != nil { log.Errorf("Could not load/create config file: %s\n", err) return } + serverConfig.ServerReporting.LogMetricsToFile = !disableMetrics // we don't need real randomness for the port, just to avoid a possible conflict... mrand.Seed(int64(time.Now().Nanosecond())) controlPort := mrand.Intn(1000) + 9052