aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/commands/servers/lighttpd.rb5
-rw-r--r--railties/lib/commands/servers/webrick.rb3
-rw-r--r--railties/lib/webrick_server.rb4
3 files changed, 9 insertions, 3 deletions
diff --git a/railties/lib/commands/servers/lighttpd.rb b/railties/lib/commands/servers/lighttpd.rb
index 0205e10c0a..6e3da4a9f8 100644
--- a/railties/lib/commands/servers/lighttpd.rb
+++ b/railties/lib/commands/servers/lighttpd.rb
@@ -52,5 +52,6 @@ else
end)
end
-trap(:INT) {exit}
-`lighttpd #{!detach ? "-D " : ""}-f #{config_file}`
+trap(:INT) { exit }
+Thread.new { sleep 0.5; `open http://0.0.0.0:#{port}` } if RUBY_PLATFORM =~ /darwin/
+`lighttpd #{!detach ? "-D " : ""}-f #{config_file}` \ No newline at end of file
diff --git a/railties/lib/commands/servers/webrick.rb b/railties/lib/commands/servers/webrick.rb
index db8e8b3d93..d06e3309bd 100644
--- a/railties/lib/commands/servers/webrick.rb
+++ b/railties/lib/commands/servers/webrick.rb
@@ -8,7 +8,8 @@ OPTIONS = {
:server_root => File.expand_path(RAILS_ROOT + "/public/"),
:server_type => WEBrick::SimpleServer,
:charset => "UTF-8",
- :mime_types => WEBrick::HTTPUtils::DefaultMimeTypes
+ :mime_types => WEBrick::HTTPUtils::DefaultMimeTypes,
+ :open_in_browser => true
}
ARGV.options do |opts|
diff --git a/railties/lib/webrick_server.rb b/railties/lib/webrick_server.rb
index f356eaf35e..74d5c08488 100644
--- a/railties/lib/webrick_server.rb
+++ b/railties/lib/webrick_server.rb
@@ -66,6 +66,10 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
require File.join(@server_options[:server_root], "..", "config", "environment") unless defined?(RAILS_ROOT)
require "dispatcher"
+ if options[:open_in_browser] && RUBY_PLATFORM =~ /darwin/
+ Thread.new { sleep 0.5; `open http://#{options[:ip]}:#{options[:port]}` }
+ end
+
server.start
end