Created
March 17, 2009 07:24
-
-
Save deepthawtz/80386 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "thin" | |
| module Merb | |
| module Rack | |
| class Thin < Merb::Rack::AbstractAdapter | |
| # start a Thin server on given host and port. | |
| # :api: plugin | |
| def self.new_server(port) | |
| Merb::Dispatcher.use_mutex = false | |
| if (@opts[:socket] || @opts[:socket_file]) | |
| socket = port.to_s | |
| socket_file = @opts[:socket_file] || "#{Merb.log_path}/#{Merb::Config[:name]}.%s.sock" | |
| socket_file = socket_file % port | |
| Merb.logger.warn!("Using Thin adapter with socket file #{socket_file}.") | |
| @server = ::Thin::Server.new(socket_file, @opts[:app], @opts) | |
| else | |
| Merb.logger.warn!("Using Thin adapter on host #{@opts[:host]} and port #{port}.") | |
| @opts[:host] = "#{@opts[:host]}-#{port}" if @opts[:host].include?('/') | |
| @server = ::Thin::Server.new(@opts[:host], port, @opts[:app], @opts) | |
| end | |
| end | |
| # :api: plugin | |
| def self.start_server | |
| ::Thin::Logging.silent = true | |
| @server.start | |
| end | |
| # :api: plugin | |
| def self.stop(status = 0) | |
| if @server | |
| @server.stop | |
| true | |
| end | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment