Feature #17847


`ruby -run -e httpd` displays URL

Added by gotoken (Kentaro Goto) about 1 year ago. Updated 9 months ago.

Target version:


The current version of un.rb httpd shows port number only:

$ ruby -run -e httpd
[2021-05-03 21:55:09] INFO  WEBrick 1.7.0
[2021-05-03 21:55:09] INFO  ruby 3.1.0 (2021-05-03) [x86_64-linux]
[2021-05-03 21:55:09] INFO  WEBrick::HTTPServer#start: pid=32129 port=8080

To access this server, we have to type in the address bar of browser.

This feature request appends URLs as follows:

[2021-05-03 21:55:15] INFO  WEBrick 1.7.0
[2021-05-03 21:55:15] INFO  ruby 3.1.0 (2021-05-03) [x86_64-linux]
[2021-05-03 21:55:15] INFO  WEBrick::HTTPServer#start: pid=32182 port=8080
[2021-05-03 21:55:15] INFO  To access this server, open this file in a browser:
[2021-05-03 21:55:15] INFO
[2021-05-03 21:55:15] INFO      http://[::1]:8080

This is often useful. Some terminals also make URLs clickable.

Pull request:

Updated by mame (Yusuke Endoh) 9 months ago

I'd like to merge this PR soon. Let me know if you have any objection.

Updated by Eregon (Benoit Daloze) 9 months ago

Sounds fine to me.
Alternatively this could be part of the default output when starting WEBrick,
I think that would be useful in more situations.

Puma does this for instance.

Updated by gotoken (Kentaro Goto) 9 months ago

  • Assignee set to gotoken (Kentaro Goto)
  • Status changed from Open to Closed

Alternatively this could be part of the default output when starting WEBrick,

That's a good idea. However, since the definition of the port number output is in the HTTPServer superclass WEBrick::GenericServer, the amount of change is likely to be a little large, so I will leave it for future work. Thanks for comment anyway.


Also available in: Atom PDF