Browse Source

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 7 years ago
parent
commit
c1e71a7081
3 changed files with 14 additions and 9 deletions
  1. 5
    2
      README.md
  2. 3
    3
      doc/pprof.md
  3. 6
    4
      internal/driver/cli.go

+ 5
- 2
README.md View File

79
 
79
 
80
 ## Run pprof via a web interface
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
 the specified host:port that provides an interactive web-based interface to pprof.
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
 The preceding command should automatically open your web browser at
92
 The preceding command should automatically open your web browser at

+ 3
- 3
doc/pprof.md View File

54
 
54
 
55
 ## Web interface
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
 pprof will start serving HTTP requests on the specified port.  Visit
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
 in a browser to see the interface.
63
 in a browser to see the interface.
64
 
64
 
65
 # Details
65
 # Details

+ 6
- 4
internal/driver/cli.go View File

110
 		return nil, nil, err
110
 		return nil, nil, err
111
 	}
111
 	}
112
 	if cmd != nil && *flagHTTP != "" {
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
 	si := pprofVariables["sample_index"].value
116
 	si := pprofVariables["sample_index"].value
268
 interface at the specified host:port that can be used to navigate through
268
 interface at the specified host:port that can be used to navigate through
269
 various views of a profile.
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
 Details:
273
 Details:
274
 `
274
 `
292
 
292
 
293
 var usageMsgVars = "\n\n" +
293
 var usageMsgVars = "\n\n" +
294
 	"  Misc options:\n" +
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
 	"\n" +
299
 	"\n" +
298
 	"  Legacy convenience options:\n" +
300
 	"  Legacy convenience options:\n" +
299
 	"   -inuse_space           Same as -sample_index=inuse_space\n" +
301
 	"   -inuse_space           Same as -sample_index=inuse_space\n" +