From ec7609ed8c93ebf7e69158d69b86f427727b271f Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Wed, 19 Aug 2020 14:09:48 +0100 Subject: [PATCH] Add debug flag; warning label for debug mode --- config/config-base.json | 3 ++- data/config-base.json | 3 ++- main.go | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config/config-base.json b/config/config-base.json index 08dd0e2..ec125aa 100644 --- a/config/config-base.json +++ b/config/config-base.json @@ -147,7 +147,8 @@ "required": false, "requires_restart": true, "type": "bool", - "value": false + "value": false, + "description": "Enables debug logging and exposes pprof as a route (Don't use in production!)" }, "contact_message": { "name": "Contact message", diff --git a/data/config-base.json b/data/config-base.json index e471b08..72e9b8f 100644 --- a/data/config-base.json +++ b/data/config-base.json @@ -184,7 +184,8 @@ "required": false, "requires_restart": true, "type": "bool", - "value": false + "value": false, + "description": "Enables debug logging and exposes pprof as a route (Don't use in production!)" }, "contact_message": { "name": "Contact message", diff --git a/main.go b/main.go index 81c51e2..9f34ebe 100644 --- a/main.go +++ b/main.go @@ -108,6 +108,7 @@ func main() { configPath := flag.String("config", app.config_path, "alternate path to config file.") host := flag.String("host", "", "alternate address to host web ui on.") port := flag.Int("port", 0, "alternate port to host web ui on.") + debug := flag.Bool("debug", false, "Enables debug logging and exposes pprof.") flag.Parse() if app.config_path == *configPath && app.data_path != *dataPath { @@ -164,8 +165,12 @@ func main() { } app.version = app.config.Section("jellyfin").Key("version").String() - debugMode = app.config.Section("ui").Key("debug").MustBool(true) + debugMode = app.config.Section("ui").Key("debug").MustBool(false) + if *debug { + debugMode = true + } if debugMode { + app.info.Println("WARNING: Don't use debug mode in production, as it exposes pprof on the network.") app.debug = log.New(os.Stdout, "[DEBUG] ", log.Ltime|log.Lshortfile) } else { app.debug = log.New(ioutil.Discard, "", 0)