2011-01-31 3 views
13

내 dev/test 환경에서 기본적으로 모든 응용 프로그램에 대해 Thin 웹 서버를 실행합니다. 내가 Mongrel with Rails 2.x를 사용할 때 입력해야하는 것은 script/server이었습니다. 그러나 Rails 3에서는 매번 Thin을 지정해야합니다. rails s thin 대신 rails s을 입력하기 만하면 Rails 앱에서 Thin을 실행할 수 있습니까?Rails 3.0.x가 기본적으로 Thin을 사용할 수있는 방법이 있습니까?

답변

0

간단히 설치하여 응용 프로그램이있는 디렉토리에 CD를 넣고 씬 시작을 실행하십시오. 여기에서 완벽하게 작동합니다. :)

필요에 따라 http://www.softiesonrails.com/2008/4/27/using-thin-instead-of-mongrel을 사용할 수 있습니다. (내가 사용했던 것)

+1

업데이트로 thin -V start는 각 연결에서 터미널의 출력을 볼 수있는 레일 서버를 시작할 때 일반적으로 나타나는 동작을 모방하여 작동합니다. – ddd

+2

멋지다. 레일스를 '얇은 시작'으로 만드는 것은 아무것도 없다. – tubbo

21

네, 가능합니다.

하루가 끝날 때 rails s 명령이 작동하는 방식은 랙으로 넘어가 서버를 선택하게하는 것입니다. 기본적으로 랙 처리기는 mongrel을 사용하려고 시도하고 mongrel을 찾을 수없는 경우 webrick과 함께 사용합니다. 핸들러를 약간 패치하면됩니다. 패치를 rails 스크립트 자체에 삽입해야합니다. 여기에 당신이 무엇을하고, 당신의 script/rails 파일을 열어보십시오. 기본적으로는 다음과 같아야합니다

#!/usr/bin/env ruby 
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 

APP_PATH = File.expand_path('../../config/application', __FILE__) 
require File.expand_path('../../config/boot', __FILE__) 
require 'rails/commands' 

우리는 require 'rails/commands' 라인 전에 우리의 패치 권리를 삽입합니다. 우리의 새로운 파일은 다음과 같이한다 : 지금 잡종을 시도하고있는 경우 오류가 얇은 노력 만 다음에 WEBrick과 함께 갈 것을

#!/usr/bin/env ruby 
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 

APP_PATH = File.expand_path('../../config/application', __FILE__) 
require File.expand_path('../../config/boot', __FILE__) 
require 'rack/handler' 
Rack::Handler.class_eval do 
    def self.default(options = {}) 
    # Guess. 
    if ENV.include?("PHP_FCGI_CHILDREN") 
     # We already speak FastCGI 
     options.delete :File 
     options.delete :Port 

     Rack::Handler::FastCGI 
    elsif ENV.include?("REQUEST_METHOD") 
     Rack::Handler::CGI 
    else 
     begin 
     Rack::Handler::Mongrel 
     rescue LoadError 
     begin 
      Rack::Handler::Thin 
     rescue LoadError 
      Rack::Handler::WEBrick 
     end 
     end 
    end 
    end 
end 
require 'rails/commands' 

공지 사항. 이제 rails s을 입력하면 우리가하는 행동을 얻게됩니다. 뿐만 아니라 script/rails 다음 작품을에서

1

: 레일 3.2rc2의로

APP_PATH = File.expand_path('../../config/application', __FILE__) 
require File.expand_path('../../config/boot', __FILE__) 

require 'rack/handler' 
Rack::Handler::WEBrick = Rack::Handler::Thin 

require 'rails/commands' 
관련 문제