Class: EmmyExtends::Thin::Controller
- Inherits:
-
Thin::Controllers::Controller
- Object
- Thin::Controllers::Controller
- EmmyExtends::Thin::Controller
- Defined in:
- lib/emmy_extends/thin/controller.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#backend ⇒ Object
Returns the value of attribute backend.
-
#config ⇒ Object
Returns the value of attribute config.
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(config, app, opts = {}) ⇒ Controller
constructor
A new instance of Controller.
- #setup ⇒ Object
- #start ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(config, app, opts = {}) ⇒ Controller
Returns a new instance of Controller.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/emmy_extends/thin/controller.rb', line 9 def initialize(config, app, opts={}) @app = app @config = config.is_a?(Hash) ? EmmyHttp::Configuration.new(config) : config = { environment: config.environment, address: config.url.host, port: config.url.port, pid: config.pid, user: config.user, group: config.group, log: config.log || File.join(Dir.pwd, "log/#{config.backend}.log") } if config.ssl .merge!( ssl: true, ssl_key_file: config.ssl.private_key_file, ssl_cert_file: config.ssl.cert_chain_file, ssl_disable_verify: !config.ssl.verify_peer, ssl_version: config.ssl.ssl_version ) end super(option_defaults.merge(.merge(opts))) setup end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
4 5 6 |
# File 'lib/emmy_extends/thin/controller.rb', line 4 def app @app end |
#backend ⇒ Object
Returns the value of attribute backend.
7 8 9 |
# File 'lib/emmy_extends/thin/controller.rb', line 7 def backend @backend end |
#config ⇒ Object
Returns the value of attribute config.
5 6 7 |
# File 'lib/emmy_extends/thin/controller.rb', line 5 def config @config end |
#server ⇒ Object
Returns the value of attribute server.
6 7 8 |
# File 'lib/emmy_extends/thin/controller.rb', line 6 def server @server end |
Instance Method Details
#setup ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/emmy_extends/thin/controller.rb', line 39 def setup if @options[:socket] @server = ::Thin::Server.new(@options[:socket], @options) else @server = ::Thin::Server.new(config.url.host, config.url.port, @options) end server.backend.url = config.url # Set options server.pid_file = @options[:pid] server.log_file = @options[:log] server.timeout = @options[:timeout] server.maximum_connections = @options[:max_conns] server.maximum_persistent_connections = @options[:max_persistent_conns] server.threaded = @options[:threaded] server.no_epoll = @options[:no_epoll] if server.backend.respond_to?(:no_epoll=) server.threadpool_size = @options[:threadpool_size] if server.threaded? # ssl support if @options[:ssl] server.ssl = true server. = { private_key_file: @options[:ssl_key_file], cert_chain_file: @options[:ssl_cert_file], verify_peer: !@options[:ssl_disable_verify], ssl_version: @options[:ssl_version] } end # Detach the process, after this line the current process returns server.daemonize if @options[:daemonize] # +config+ must be called before changing privileges since it might require superuser power. server.config server.change_privilege @options[:user], @options[:group] if @options[:user] && @options[:group] server.app = app #server.on_restart { Thin::Command.run(:start, @options) } # just return thin-backend @backend = server.backend end |
#start ⇒ Object
36 37 |
# File 'lib/emmy_extends/thin/controller.rb', line 36 def start end |
#to_a ⇒ Object
84 85 86 |
# File 'lib/emmy_extends/thin/controller.rb', line 84 def to_a @backend.to_a end |