我想成为世界级的软件开发者。现在读大学三年级。欢迎发E-mail与我讨论关于软件开发的各种想法。 我的新blog在http://redworld.blog.ubuntu.org.cn/

thin简介

上一篇 / 下一篇  2008-01-10 10:01:54 / 个人分类:Ruby

查看( 36 ) / 评论( 3 )


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

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

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



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

首先安装thin:

CODE:

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

CODE:

thin start运行成功:

CODE:

>> Thin web server (v0.5.0)
>> Listening on 0.0.0.0:3000, CTRL+C to stop
另外一个运行thin的方法(通过Rack的rackup命令):
在你的Rails应用根目录下创建一个名为config.ru的文件:

CODE:

require 'rubygems'
require 'thin'

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

run app
然后就执行

CODE:

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 10:05 编辑]

TAG: rails ruby thin

SKYOVER之陋室 admin 发布于2008-01-10 20:41:41
新技术,新产品真是层出不穷啊。呵呵,看来值得试用。
我有红宝石 bayerlin 发布于2008-01-15 09:27:44
好东西,可以这样做集群
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
red_world maninred 发布于2008-01-21 00:17:30
对岸的网友的接着讨论:
http://lightyror.thegiive.net/20 ... rel-app-server.html
我来说两句

(可选)

日历

« 2009-01-08  
    123
45678910
11121314151617
18192021222324
25262728293031

数据统计

  • 访问量: 1600
  • 日志数: 63
  • 书签数: 3
  • 建立时间: 2007-10-09
  • 更新时间: 2008-02-15

RSS订阅

Open Toolbar