Quellcode durchsuchen

Make it obvious that host and port are both optional (#204)

* doc: make it obvious that host and port are both optional

* fix minor issue

* address comments
JBD vor 7 Jahren
Ursprung
Commit
c1e71a7081
3 geänderte Dateien mit 14 neuen und 9 gelöschten Zeilen
  1. 5
    2
      README.md
  2. 3
    3
      doc/pprof.md
  3. 6
    4
      internal/driver/cli.go

+ 5
- 2
README.md Datei anzeigen

@@ -79,11 +79,14 @@ Type 'help' for available commands/options.
79 79
 
80 80
 ## Run pprof via a web interface
81 81
 
82
-If the `-http="host:port"` option is specified, pprof starts a web server at
82
+If the `-http` flag is specified, pprof starts a web server at
83 83
 the specified host:port that provides an interactive web-based interface to pprof.
84
+Host is optional, and is "localhost" by default. Port is optional, and is a
85
+random available port by default. `-http=":"` starts a server locally at
86
+a random port.
84 87
 
85 88
 ```
86
-pprof -http=[host:port] [main_binary] profile.pb.gz
89
+pprof -http=[host]:[port] [main_binary] profile.pb.gz
87 90
 ```
88 91
 
89 92
 The preceding command should automatically open your web browser at

+ 3
- 3
doc/pprof.md Datei anzeigen

@@ -54,12 +54,12 @@ commands.  Type `help` to get online help.
54 54
 
55 55
 ## Web interface
56 56
 
57
-If a port is specified on the command line:
57
+If a host:port is specified on the command line:
58 58
 
59
-    pprof -http=<port> [options] source
59
+    pprof -http=[host]:[port] [options] source
60 60
 
61 61
 pprof will start serving HTTP requests on the specified port.  Visit
62
-the HTTP url corresponding to the port (typically `http://localhost:<port>/`)
62
+the HTTP url corresponding to the port (typically `http://<host>:<port>/`)
63 63
 in a browser to see the interface.
64 64
 
65 65
 # Details

+ 6
- 4
internal/driver/cli.go Datei anzeigen

@@ -110,7 +110,7 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
110 110
 		return nil, nil, err
111 111
 	}
112 112
 	if cmd != nil && *flagHTTP != "" {
113
-		return nil, nil, fmt.Errorf("--http is not compatible with an output format on the command line")
113
+		return nil, nil, fmt.Errorf("-http is not compatible with an output format on the command line")
114 114
 	}
115 115
 
116 116
 	si := pprofVariables["sample_index"].value
@@ -268,7 +268,7 @@ Omit the format and provide the "-http" flag to get an interactive web
268 268
 interface at the specified host:port that can be used to navigate through
269 269
 various views of a profile.
270 270
 
271
-   pprof -http <host:port> [options] [binary] <source> ...
271
+   pprof -http [host]:[port] [options] [binary] <source> ...
272 272
 
273 273
 Details:
274 274
 `
@@ -292,8 +292,10 @@ var usageMsgSrc = "\n\n" +
292 292
 
293 293
 var usageMsgVars = "\n\n" +
294 294
 	"  Misc options:\n" +
295
-	"   -http host:port        Provide web based interface at host:port\n" +
296
-	"   -tools                 Search path for object tools\n" +
295
+	"   -http              Provide web based interface at host:port.\n" +
296
+	"                      Host is optional and 'localhost' by default.\n" +
297
+	"                      Port is optional and a randomly available port by default.\n" +
298
+	"   -tools             Search path for object tools\n" +
297 299
 	"\n" +
298 300
 	"  Legacy convenience options:\n" +
299 301
 	"   -inuse_space           Same as -sample_index=inuse_space\n" +