Skip to content

Commit

Permalink
ui-ip cli option available
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter committed Mar 12, 2024
1 parent f3fbfda commit bd489d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func handleClientPeek(clients *Clients) func(w http.ResponseWriter, r *http.Requ
}
}

func handleHttp(msgs <-chan models.Message, httpPort string, analyticsEnabled bool, uiPass string, configFilePath string, bulkWindowMs int64, maxMessageCount int64) {
func handleHttp(msgs <-chan models.Message, httpPort string, uiIp string, analyticsEnabled bool, uiPass string, configFilePath string, bulkWindowMs int64, maxMessageCount int64) {
assets, _ := Assets()
clients := NewClients(msgs, maxMessageCount)

Expand All @@ -368,7 +368,11 @@ func handleHttp(msgs <-chan models.Message, httpPort string, analyticsEnabled bo

utils.Logger.WithFields(logrus.Fields{
"port": httpPort,
}).Info("WebUI started, visit http://localhost:" + httpPort)
}).Info("WebUI started, visit http://" + uiIp + ":" + httpPort)

http.ListenAndServe(":"+httpPort, nil)
err := http.ListenAndServe(uiIp+":"+httpPort, nil)

if err != nil {
panic(err)
}
}
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ where you can filter and browse well formatted application output.
}

httpPort, _ := cmd.Flags().GetString("port")
uiIp, _ := cmd.Flags().GetString("ui-ip")
uiPass, _ := cmd.Flags().GetString("ui-pass")
configFile, _ := cmd.Flags().GetString("config")
noanalytics, _ := cmd.Flags().GetBool("no-analytics")
Expand All @@ -62,7 +63,7 @@ where you can filter and browse well formatted application output.
utils.Logger.SetLevel(logrus.InfoLevel)
}

handleHttp(ch, httpPort, !noanalytics, uiPass, configFile, bulkWindow, maxMessageCount)
handleHttp(ch, httpPort, uiIp, !noanalytics, uiPass, configFile, bulkWindow, maxMessageCount)
},
}

Expand Down Expand Up @@ -141,6 +142,7 @@ var demoSocketCmd = &cobra.Command{
func init() {
ch = make(chan models.Message, 1000)
rootCmd.PersistentFlags().StringP("port", "p", "8080", "Port on which the Web UI will be served")
rootCmd.PersistentFlags().StringP("ui-ip", "", "127.0.0.1", "Bind Web UI server to a specific IP address")
rootCmd.PersistentFlags().StringP("ui-pass", "", "", "Password that will be used to authenticate in the UI")
rootCmd.PersistentFlags().StringP("config", "", "", "Path to a file where a config (json) for the UI is located")
rootCmd.PersistentFlags().Int64P("bulk-window", "", 100, "A time window during which log messages are gathered and send in a bulk to a client. Decreasing this window will improve the 'real-time' feeling of messages presented on the screen but could decrease UI performance")
Expand Down

0 comments on commit bd489d0

Please sign in to comment.