<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SNS開発者の雑記帳 &#187; プログラミング</title>
	<atom:link href="http://www.synapz.jp/mrsy/category/%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%9f%e3%83%b3%e3%82%b0/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.synapz.jp/mrsy</link>
	<description></description>
	<lastBuildDate>Fri, 05 Mar 2010 02:11:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rails 環境調査</title>
		<link>http://www.synapz.jp/mrsy/2008/04/rails/</link>
		<comments>http://www.synapz.jp/mrsy/2008/04/rails/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 05:19:31 +0000</pubDate>
		<dc:creator>mrsy</dc:creator>
				<category><![CDATA[プログラミング]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.synapz.jp/mrsy/2008/04/18/post51/</guid>
		<description><![CDATA[
最近Ruby on Railsの面白さにハマり、いろいろネットで情報を収集しています。
皆さん様々な環境やサーバソフトウェアの組み合わせで試みているようですね。
今回はRailsアプリケーションを動かす環境について、自分なりのまとめです。

httpサーバ

lighttpd

その名の通り、「軽い」httpサーバ。また、安全で柔軟性もあるとされる。
Apacheとのベンチマーク比較でも、同等かわずかに上回るパフォーマンスとのこと。



Mongrel

Rails アプリケーションサーバ。Java世界で言うところの、Jakarta Tomcat。
RubyとCの拡張ライブラリで書かれている。
Apacheをリバースプロキシとして動作させ、Railsアプリはmongrel_cluster(負荷分散や複数のRailsアプリを動作させるためのMongrelプロセス複数起動)という役割で利用されることが多い。



WEBrick

Rubyに標準添付されているhttpサーバソフトウェア。
公式ページにはhttpサーバ構築のためのライブラリと記されている。主に開発用に使用する。



WEBrick is a Ruby library program to build HTTP servers. 
via: RAA &#8211; webrick


実際にWEBrickでhttpプロキシサーバを作るチュートリアルがこちらに載っている。


httpサーバと組み合わせるモジュール

FastCGI

CGIはクライアントからhttpリクエストがある都度プロセスを立ち上げ、レスポンスを返した後にそのプロセスを落とす。このオーバーヘッドを無くそうとしたものがFastCGI。FastCGIによって起動されたCGIプログラムはHTTPDプロセスとは別に起動するが、CGIの処理が終了してもプロセスは残る。そのプロセスを使い回すことでパフォーマンスの向上が図れる。
こちらにより詳細な解説があります。



Passenger(mod_ruby)

RailsアプリケーションをApache上で動作させるためのモジュール。PHPでいうところの、mod_php。これがあればMongrelやWEBrickは不要。パフォーマンスにおいてもMongrelより（ちょっと）早いらしい。


画像は公式サイトより。
インストール方法など詳細な解説はこちら。


まとめ
最近リリースされたPassengerが一番手軽そうですが、信頼性についてはまだまだ未知数です。
]]></description>
			<content:encoded><![CDATA[<p>
最近Ruby on Railsの面白さにハマり、いろいろネットで情報を収集しています。<br />
皆さん様々な環境やサーバソフトウェアの組み合わせで試みているようですね。<br />
今回はRailsアプリケーションを動かす環境について、自分なりのまとめです。<br />
<br />
<h2>httpサーバ</h2>
<ul>
<li><strong>lighttpd</strong></li>
</ul>
その名の通り、「軽い」httpサーバ。また、安全で柔軟性もあるとされる。<br />
Apacheとのベンチマーク比較でも、同等かわずかに上回るパフォーマンスとのこと。<br />
<br />
<br />
<ul>
<li><strong>Mongrel</strong></li>
</ul>
Rails アプリケーションサーバ。Java世界で言うところの、Jakarta Tomcat。<br />
RubyとCの拡張ライブラリで書かれている。<br />
Apacheをリバースプロキシとして動作させ、Railsアプリはmongrel_cluster(負荷分散や複数のRailsアプリを動作させるためのMongrelプロセス複数起動)という役割で利用されることが多い。<br />
<br />
<br />
<ul>
<li><strong>WEBrick</strong></li>
</ul>
Rubyに標準添付されているhttpサーバソフトウェア。<br />
公式ページにはhttpサーバ構築のためのライブラリと記されている。主に開発用に使用する。<br />
<br />
</p>
<blockquote><p>
WEBrick is a Ruby library program to build HTTP servers. </p>
<cite>via: <a href="http://raa.ruby-lang.org/project/webrick" target="_blank">RAA &#8211; webrick</a></cite><br />
</p></blockquote>
<p>
実際にWEBrickでhttpプロキシサーバを作るチュートリアルが<a href="http://jp.rubyist.net/magazine/?0002-WEBrickProxy#fm01">こちら</a>に載っている。<br />
<br />
<br />
<h2>httpサーバと組み合わせるモジュール</h2>
<ul>
<li><strong>FastCGI</strong></li>
</ul>
CGIはクライアントからhttpリクエストがある都度プロセスを立ち上げ、レスポンスを返した後にそのプロセスを落とす。このオーバーヘッドを無くそうとしたものがFastCGI。FastCGIによって起動されたCGIプログラムはHTTPDプロセスとは別に起動するが、CGIの処理が終了してもプロセスは残る。そのプロセスを使い回すことでパフォーマンスの向上が図れる。<br />
<a href="http://webos-goodies.jp/archives/50816782.html">こちら</a>により詳細な解説があります。<br />
<br />
<br />
<ul>
<li><strong>Passenger(mod_ruby)</strong></li>
</ul>
RailsアプリケーションをApache上で動作させるためのモジュール。PHPでいうところの、mod_php。これがあればMongrelやWEBrickは不要。パフォーマンスにおいてもMongrelより（ちょっと）早いらしい。<br />
<br />
<img alt="passenger_mongrel_thin_benchmark.png" src="http://www.synapz.jp/blog/mrsy/2008/04/18/passenger_mongrel_thin_benchmark.png" width="470" height="292" class="mt-image-center">
画像は<a href="http://www.modrails.com/documentation.html">公式サイト</a>より。<br />
インストール方法など詳細な解説は<a href="http://rails20.jp/2008/04/passenger/">こちら</a>。<br />
<br />
<br />
<h2>まとめ</h2>
最近リリースされたPassengerが一番手軽そうですが、信頼性についてはまだまだ未知数です。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.synapz.jp/mrsy/2008/04/rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rubyでデザインパターン -Command-</title>
		<link>http://www.synapz.jp/mrsy/2008/04/ruby-command/</link>
		<comments>http://www.synapz.jp/mrsy/2008/04/ruby-command/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 09:44:09 +0000</pubDate>
		<dc:creator>mrsy</dc:creator>
				<category><![CDATA[プログラミング]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[デザインパターン]]></category>

		<guid isPermaLink="false">http://www.synapz.jp/mrsy/2008/04/01/post49/</guid>
		<description><![CDATA[
最近Rubyを勉強してます（遅いって？）。Rubyのソースを見る度に、なぜか受け付け難い雰囲気を感じていたのですが、最近会う人会う人がRuby(on Rails)で開発しているよ的な発言をされているので、やむにやまれず触発された感じです。

言語学習はやっぱりコード書かなきゃと思いましたので、ここに晒す次第です。あまりデザインパターンに意味はありません。

クラス図



CommandExecutor.rb
class CommandExecutor
def initialize
@commands = Array.new
end
def setCommand cmd
@commands &#60;&#60; cmd
end
def execute
@commands.each do &#124;cmd&#124;
cmd.execute
end
end
end



AbstractCommand.rb
class AbstractCommand
def initialize
@option     = '';
@command    = '';
end
def execute
%x{@command};
end
def setOption opt
@option = opt
end
end



CurrentDirCommand.rb
require 'AbstractCommand.rb'
class CurrentDirCommand &#60; AbstractCommand
def initialize
@command = &#39;pwd&#39;;
end
def execute
STDOUT &#60;&#60; %x{#{@command}}
end
end



ListCommand.rb
require 'AbstractCommand.rb'
class ListCommand &#60; AbstractCommand
def initialize
@command = &#39;ls&#39;;
end
def execute
if @option.nil? then
cmd = @command
else
cmd = @command [...]]]></description>
			<content:encoded><![CDATA[<p>
最近Rubyを勉強してます（遅いって？）。Rubyのソースを見る度に、なぜか受け付け難い雰囲気を感じていたのですが、最近会う人会う人がRuby(on Rails)で開発しているよ的な発言をされているので、やむにやまれず触発された感じです。<br />
<br />
言語学習はやっぱりコード書かなきゃと思いましたので、ここに晒す次第です。あまりデザインパターンに意味はありません。<br />
<br />
<strong><big>クラス図</big></strong><br /><br />
<img src="http://www.synapz.jp/blog/mrsy/2008/04/01/class-thumb-500x202.png" width="500" height="202" alt="class.png" class="mt-image-center" style="text-align: center;margin: 0 auto 20px" />
<br />
<br />
<strong><big>CommandExecutor.rb</big></strong><br />
<pre><code>class CommandExecutor
def initialize
@commands = Array.new
end
def setCommand cmd
@commands &lt;&lt; cmd
end
def execute
@commands.each do |cmd|
cmd.execute
end
end
end
</code></pre>
<br />
<br />
<strong><big>AbstractCommand.rb</big></strong><br />
<pre><code>class AbstractCommand
def initialize
@option     = '';
@command    = '';
end
def execute
%x{@command};
end
def setOption opt
@option = opt
end
end
</code></pre>
<br />
<br />
<strong><big>CurrentDirCommand.rb</big></strong><br />
<pre><code>require 'AbstractCommand.rb'
class CurrentDirCommand &lt; AbstractCommand
def initialize
@command = &#39;pwd&#39;;
end
def execute
STDOUT &lt;&lt; %x{#{@command}}
end
end
</code></pre>
<br />
<br />
<strong><big>ListCommand.rb</big></strong><br />
<pre><code>require 'AbstractCommand.rb'
class ListCommand &lt; AbstractCommand
def initialize
@command = &#39;ls&#39;;
end
def execute
if @option.nil? then
cmd = @command
else
cmd = @command + @option
end
result = %x{#{cmd}}.split(/\n/)
STDOUT &lt;&lt; result.join(&quot;\n&quot;) + &quot;\n&quot;
end
end
</code></pre>
<br />
<br />
<strong><big>MakeDirCommand.rb</big></strong><br />
<pre><code>require 'AbstractCommand.rb'
class MakeDirCommand &lt; AbstractCommand
def initialize
@command = &#39;mkdir&#39;;
end
def execute
if @option.nil? then
cmd = @command
else
cmd = @command + @option
end
STDOUT &lt;&lt; %x{#{cmd}}
end
end
</code></pre>
<br />
<br />
<strong><big>main.rb</big></strong><br />
<pre><code>#!/usr/bin/ruby
require 'CommandExecutor'
require 'ListCommand'
require 'CurrentDirCommand'
require 'MakeDirCommand'
# コマンド実行オブジェクトを new
executor = CommandExecutor.new
# pwd コマンド追加
pwd = CurrentDirCommand.new
executor.setCommand pwd
# lsコマンド追加
ls = ListCommand.new
ls.setOption ' -lk'
executor.setCommand ls
# mkdir コマンド追加
mkdir = MakeDirCommand.new
mkdir.setOption ' tmp'
executor.setCommand mkdir
# 全部実行
executor.execute
exit
</code></pre>
<br />
<a href="http://www.ruby-lang.org/ja/man/html/_A5AFA5E9A5B9A1BFA5E1A5BDA5C3A5C9A4CEC4EAB5C1.html#a.b8.c6.a4.d3.bd.d0.a4.b7.c0.a9.b8.c2">呼び出し制限</a>がJavaとは異なっていて、いまいち理解できてません。<br />
<br />
でも細かいとこですが、括弧やセミコロン省略できるだけでも、よりプログラムの本質に集中できるというかタイピング数が少なくなるせいか、生産性は高いかもしれません。<br />
<br />
どなたかこのソースに突っ込んでください。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.synapz.jp/mrsy/2008/04/ruby-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

