good morning!!!!

Skip to content
Snippets Groups Projects
Commit e67c1062 authored by aforge's avatar aforge
Browse files

Allow overriding status path with configs and cmd line.

parent 55e80309
Branches fixes
Tags
No related merge requests found
......@@ -384,7 +384,6 @@ func serveStatus(wrt http.ResponseWriter, req *http.Request) {
now := time.Now()
fmt.Fprintf(wrt, "<body>")
fmt.Fprintf(wrt, "<h1>%s</h1><div>Version: %s, build: %s. Present time: %s</div>", "Tinode Server", currentVersion, buildstamp, now.Format(time.RFC1123))
fmt.Fprintf(wrt, "<a href='/status'>Update</a>")
fmt.Fprintf(wrt, "<br><hr>")
fmt.Fprintf(wrt, "<div>Sessions: %d</div>", len(globals.sessionStore.sessCache))
......
......@@ -233,6 +233,8 @@ type configType struct {
MaxTagCount int `json:"max_tag_count"`
// URL path for exposing runtime stats. Disabled if the path is blank.
ExpvarPath string `json:"expvar"`
// URL path for internal server status. Disabled if the path is blank.
ServerStatusPath string `json:"server_status"`
// Take IP address of the client from HTTP header 'X-Forwarded-For'.
// Useful when tinode is behind a proxy. If missing, fallback to default RemoteAddr.
UseXForwardedFor bool `json:"use_x_forwarded_for"`
......@@ -266,6 +268,7 @@ func main() {
tlsEnabled := flag.Bool("tls_enabled", false, "Override config value for enabling TLS.")
clusterSelf := flag.String("cluster_self", "", "Override the name of the current cluster node.")
expvarPath := flag.String("expvar", "", "Override the URL path where runtime stats are exposed. Use '-' to disable.")
serverStatusPath := flag.String("server_status", "", "Override the URL path where the server's internal status is displayed. Use '-' to disable.")
pprofFile := flag.String("pprof", "", "File name to save profiling info to. Disabled if not set.")
pprofUrl := flag.String("pprof_url", "", "Debugging only! URL path for exposing profiling info. Disabled if not set.")
flag.Parse()
......@@ -616,7 +619,15 @@ func main() {
}
}
logs.Info.Printf("API served from root URL path '%s'", config.ApiPath)
mux.HandleFunc("/status", serveStatus)
sspath := *serverStatusPath
if sspath == "" || sspath == "-" {
sspath = config.ServerStatusPath
}
if sspath != "" && sspath != "-" {
logs.Info.Printf("Server status is available at '%s'", sspath)
mux.HandleFunc(sspath, serveStatus)
}
// Handle websocket clients.
mux.HandleFunc(config.ApiPath+"v0/channels", serveWebSocket)
......
......@@ -46,6 +46,10 @@
// Could be overriden from the command line with --expvar.
"expvar": "/debug/vars",
// URL path for internal server status. Disabled if the path is blank or "-".
// Could be overriden from the command line with --server_status.
"server_status": "/status",
// Read IP address of the client from the HTTP header 'X-Forwarded-For'.
// Useful when Tinode is behind a proxy. If missing, fallback to default RemoteAddr.
"use_x_forwarded_for": true,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment