打印

thin简介

本帖已经被作者加入个人空间

thin简介



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

thin是个合成品,分别使用了来自mongrel的解析器,Every Machine的网络IO库,Rack的web服务器和Ruby框架的接口。

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



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

首先安装thin:

gem install thin


然后要运行thin服务器就在你的根目录下执行:

thin start


运行成功:

>> Thin web server (v0.5.0)
>> Listening on 0.0.0.0:3000, CTRL+C to stop


另外一个运行thin的方法(通过Rack的rackup命令):
在你的Rails应用根目录下创建一个名为config.ru的文件:

require 'rubygems'
require 'thin'

app = proc do |env|
  [ 200, { 'Content-Type' => 'text/html' }, ['hi'] ]
end

run app


然后就执行

rackup -s thin


这样也可以运行thin服务器。

本文相关资料:
http://code.macournoyer.com/thin/
http://mongrel.rubyforge.org/
http://rubyeventmachine.com/
http://rack.rubyforge.org/

另:
Rack支持的服务器:

  •   Mongrel
  •   Mongrel/Swiftcore
  •   WEBrick
  •   FCGI
  •   CGI


[ 本帖最后由 maninred 于 2008-1-10 15:03 编辑 ]
###
blog => red_world,
mail => [image]http://services.nexodyne.com/email/icon/NTbKP7EQRA%3D%3D/c2n6Sgw%3D/R01haWw%3D/0/image.png[/image]
###

TOP

新技术,新产品真是层出不穷啊。呵呵,看来值得试用。
谢谢大家加入Ruby中文社区!
[寻找您身边的Rubyist.]

TOP

好东西,可以这样做集群

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
success = 9999999.times{ handle ruby }
广东民声热线

TOP

###
blog => red_world,
mail => [image]http://services.nexodyne.com/email/icon/NTbKP7EQRA%3D%3D/c2n6Sgw%3D/R01haWw%3D/0/image.png[/image]
###

TOP

2010-09-03 16:16 Crawled by CCBot/1.0 (+http://www.commoncrawl.org/bot.html) @38.107.191.96