Ticket #422: server_thin_adapter.patch

File server_thin_adapter.patch, 2.1 kB (added by kevw..@gmail.com, 6 months ago)
  • lib/merb/server.rb

    old new  
    169169            options[:fastcgi] = true 
    170170          end 
    171171           
     172          opts.on("-t", "--thin", "Run merb using Thin Rack Adapter instead of mongrel.") do 
     173            options[:thin] = true 
     174          end 
     175           
    172176          opts.on("-X", "--mutex on/off", "This flag is for turning the mutex lock on and off.") do |mutex| 
    173177            if mutex == 'off' 
    174178              options[:use_mutex] = false 
     
    573577          puts "Starting merb webrick server on port: #{@@merb_opts[:port]}" 
    574578          trap('TERM') { exit } 
    575579          webrick_start(@@merb_opts[:port]) 
     580          exit! 
    576581        end 
    577582         
    578583        if @@merb_opts[:fastcgi]  
    579584          trap('TERM') { exit } 
    580585          fastcgi_start 
     586          exit! 
    581587        end 
    582588         
     589        if @@merb_opts[:thin] 
     590          puts "Starting merb thin server on port #{@@merb_opts[:port]}" 
     591          trap('TERM') { exit } 
     592          thin_start(@@merb_opts[:port]) 
     593          exit! 
     594        end 
    583595         
     596         
    584597        if @@merb_opts[:cluster] 
    585598          delete_pidfiles 
    586599          @@merb_opts[:port].to_i.upto(@@merb_opts[:port].to_i+@@merb_opts[:cluster].to_i-1) do |port| 
     
    635648        ::Rack::Handler::FastCGI.run Merb::Rack::Adapter.new 
    636649      end 
    637650       
     651      def thin_start(port) 
     652        initialize_merb 
     653        require 'thin' 
     654        require 'merb/rack_adapter' 
     655        ::Rack::Handler::Thin.run Merb::Rack::Adapter.new, :Host => @@merb_opts[:host], :Port => port 
     656      end 
     657       
    638658      def delete_pidfiles(portor_star='*') 
    639659        Dir["#{@@merb_opts[:merb_root]}/log/merb.#{portor_star}.pid"].each do |pid| 
    640660          FileUtils.rm(pid)  rescue nil 
     
    657677          puts @@merb_opts.to_yaml; puts 
    658678        end 
    659679        initialize_merb 
    660        
     680 
    661681        mconf_hash = {:host => (@@merb_opts[:host]||"0.0.0.0"), :port => (port ||4000)} 
    662682        if @@merb_opts[:user] and @@merb_opts[:group] 
    663683          mconf_hash[:user]   = @@merb_opts[:user]