thin简介

thin简介



官方主页:http://code.macournoyer.com/thin/

thin是个合成品,分别使用了来自mongrel的解析器,Every Machine的网络IO库,Rack的web服务器和php?name=Ruby" onclick="tagshow(event)" class="t_tag">Ruby框架的接口。

也就是说thin有mongrel的速度和安全性,有Every Machine的高伸缩性,性能和稳定性。



那如何在你的Rails中使用thin呢?

首先安装thin:

[Copy to clipboard] [ - ]
新技术,新产品真是层出不穷啊。呵呵,看来值得试用。
Cool!

Here's a quick rake task to make a thin cluster:

rake thin:cluster:start
rake thin:cluster:stop

For the start task, you can pass in the RAILS_ENV and the SIZE of the cluster (default 4).

rake thin:cluster:start RAILS_ENV=production SIZE=10


namespace :thin do

namespace :cluster do

desc 'Start thin cluster'
task :start => :environment do
`cd #{RAILS_ROOT}`
port_range = RAILS_ENV == 'development' ? 3 : 8
(ENV['SIZE'] ? ENV['SIZE'].to_i : 4).times do |i|
Thread.new do
port = "#{port_range}%03d" % i
str = "thin start -d -p#{port} -Ptmp/pids/thin-#{port}.pid"
str += " -e#{RAILS_ENV}"
puts "Starting server on port #{port}..."
`#{str}`
end
end
end

desc 'Stop thin cluster'
task :stop => :environment do
`cd #{RAILS_ROOT}`
port_range = RAILS_ENV == 'development' ? 3 : 8
Dir.new("#{RAILS_ROOT}/tmp/pids").each do |file|
Thread.new do
if file.starts_with?("thin-#{port_range}")
str = "thin stop -Ptmp/pids/#{file}"
puts "Stopping server on port #{file[/\d+/]}..."
`#{str}`
end
end
end
end

end
end
对岸的网友的接着讨论:
http://lightyror.thegiive.net/20 ... rel-app-server.html