Class: OMF::Web::Runner
- Inherits:
-
Thin::Runner
- Object
- Thin::Runner
- OMF::Web::Runner
- Includes:
- Common::Loggable
- Defined in:
- lib/omf-web/thin/runner.rb
Constant Summary collapse
- @@instance =
nil
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv, opts = {}) ⇒ Runner
constructor
A new instance of Runner.
- #life_cycle(step) ⇒ Object
- #run! ⇒ Object
Methods included from Common::Loggable
#_logger, #debug, #error, #fatal, #info, init_log, logger, set_environment, #warn
Constructor Details
#initialize(argv, opts = {}) ⇒ Runner
Returns a new instance of Runner.
28 29 30 31 32 33 34 35 36 37 38 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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/omf-web/thin/runner.rb', line 28 def initialize(argv, opts = {}) raise "SINGLETON" if @@instance @argv = argv sopts = opts.delete(:ssl) # runner has it's own idea of ssl options # Default options values app_name = opts[:app_name] || 'omf_web_app' @options = { :app_name => app_name, :chdir => Dir.pwd, :environment => 'development', :address => '0.0.0.0', :port => Thin::Server::DEFAULT_PORT, :timeout => Thin::Server::DEFAULT_TIMEOUT, :log => "/tmp/#{app_name}_thin.log", :pid => "/tmp/#{app_name}.pid", :max_conns => Thin::Server::DEFAULT_MAXIMUM_CONNECTIONS, :max_persistent_conns => Thin::Server::DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS, :require => [], :wait => Thin::Controllers::Cluster::DEFAULT_WAIT_TIME, :rackup => File.dirname(__FILE__) + '/../config.ru', :static_dirs => ["#{File.dirname(__FILE__)}/../../../share/htdocs"], :static_dirs_pre => ["./resources"], # directories to prepend to 'static_dirs' :handlers => {} # procs to call at various times of the server's life cycle }.merge(opts) # Search path for resource files is concatination of 'pre' and 'standard' static dirs @options[:static_dirs] = @options[:static_dirs_pre].concat(@options[:static_dirs]) = false p = parser p.separator "" p.separator "OMF options:" p.on("--theme THEME", "Select web theme") do |t| OMF::Web::Theme.theme = t end p.separator "" p.separator "Testing options:" p.on("--disable-https", "Run server without SSL") do sopts = nil end p.on("--print-options", "Print option settings after parsing command lines args") do = true end # Allow application to add it's own parsing options if ph = @options[:handlers][:pre_parse] ph.call(p) end parse! if sopts @options[:ssl] = true @options[:ssl_key_file] ||= sopts[:key_file] @options[:ssl_cert_file] ||= sopts[:cert_file] @options[:ssl_verify] ||= sopts[:verify_peer] end # Change the name of the root logger so we can apply different logging # policies depending on environment. # OMF::Common::Loggable.set_environment @options[:environment] if require 'pp' pp @options end @@instance = self end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
26 27 28 |
# File 'lib/omf-web/thin/runner.rb', line 26 def @options end |
Class Method Details
.instance ⇒ Object
22 23 24 |
# File 'lib/omf-web/thin/runner.rb', line 22 def self.instance @@instance end |
Instance Method Details
#life_cycle(step) ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/omf-web/thin/runner.rb', line 99 def life_cycle(step) begin if (p = @options[:handlers][step]) p.call() end rescue => ex error ex debug "#{ex.backtrace.join("\n")}" end end |