Skip to content

Commit

Permalink
Added Thin support to script/server. [#488 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxin authored and jeremy committed Jun 26, 2008
1 parent 24c7f41 commit a93ea88
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions railties/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*

* Added Thin support to script/server. #488 [Bob Klosinski]

* Fix script/about in production mode. #370 [Cheah Chu Yeow, Xavier Noria, David Krmpotic]

* Add the gem load paths before the framework is loaded, so certain gems like RedCloth and BlueCloth can be frozen.
Expand Down
14 changes: 12 additions & 2 deletions railties/lib/commands/server.rb
Expand Up @@ -13,11 +13,19 @@
# Mongrel not available
end

begin
require_library_or_gem 'thin'
rescue Exception
# Thin not available
end

server = case ARGV.first
when "lighttpd", "mongrel", "new_mongrel", "webrick"
when "lighttpd", "mongrel", "new_mongrel", "webrick", "thin"
ARGV.shift
else
if defined?(Mongrel)
if defined?(Thin)
"thin"
elsif defined?(Mongrel)
"mongrel"
elsif RUBY_PLATFORM !~ /(:?mswin|mingw)/ && !silence_stderr { `lighttpd -version` }.blank? && defined?(FCGI)
"lighttpd"
Expand All @@ -33,6 +41,8 @@
puts "=> Booting lighttpd (use 'script/server webrick' to force WEBrick)"
when "mongrel", "new_mongrel"
puts "=> Booting Mongrel (use 'script/server webrick' to force WEBrick)"
when "thin"
puts "=> Booting Thin (use 'script/server webrick' to force WEBrick)"
end

%w(cache pids sessions sockets).each { |dir_to_make| FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', dir_to_make)) }
Expand Down
25 changes: 25 additions & 0 deletions railties/lib/commands/servers/thin.rb
@@ -0,0 +1,25 @@
require 'rbconfig'
require 'commands/servers/base'
require 'thin'


options = ARGV.clone
options.insert(0,'start') unless Thin::Runner.commands.include?(options[0])

thin = Thin::Runner.new(options)

puts "=> Rails #{Rails.version} application starting on http://#{thin.options[:address]}:#{thin.options[:port]}"
puts "=> Ctrl-C to shutdown server"

log = Pathname.new("#{File.expand_path(RAILS_ROOT)}/log/#{RAILS_ENV}.log").cleanpath
open(log, (File::WRONLY | File::APPEND | File::CREAT)) unless File.exist? log
tail_thread = tail(log)
trap(:INT) { exit }

begin
thin.run!
ensure
tail_thread.kill if tail_thread
puts 'Exiting'
end

0 comments on commit a93ea88

Please sign in to comment.