Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added automatic browser launching on OS X when starting script/server…
… [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2960 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Nov 9, 2005
1 parent 5879a2e commit c7e5c27
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion railties/CHANGELOG
@@ -1,6 +1,8 @@
*SVN*

* Changed all script/* to use #!/usr/bin/env ruby instead of hard-coded Ruby path. public/dispatcher.* still uses the hard-coded path for compatibility with web servers that doesn't have Ruby in path [DHH]
* Added automatic browser launching on OS X when starting script/server [DHH]

* Changed all script/* to use #!/usr/bin/env ruby instead of hard-coded Ruby path. public/dispatcher.* still uses the hard-coded path for compatibility with web servers that don't have Ruby in path [DHH]

* Force RAILS_ENV to be "test" when running tests, so that ENV["RAILS_ENV"] = "production" in config/environment.rb doesn't wreck havok [DHH] #2660

Expand Down
5 changes: 3 additions & 2 deletions railties/lib/commands/servers/lighttpd.rb
Expand Up @@ -52,5 +52,6 @@ def tail_f(input)
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}`
3 changes: 2 additions & 1 deletion railties/lib/commands/servers/webrick.rb
Expand Up @@ -8,7 +8,8 @@
: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|
Expand Down
4 changes: 4 additions & 0 deletions railties/lib/webrick_server.rb
Expand Up @@ -66,6 +66,10 @@ def self.dispatch(options = {})
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

Expand Down

0 comments on commit c7e5c27

Please sign in to comment.