Class: Perus::Server::Server
- Inherits:
-
Object
- Object
- Perus::Server::Server
- Defined in:
- lib/perus/server/server.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options_path = DEFAULT_SERVER_OPTIONS_PATH, environment = 'development') ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
Constructor Details
#initialize(options_path = DEFAULT_SERVER_OPTIONS_PATH, environment = 'development') ⇒ Server
Returns a new instance of Server.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/perus/server/server.rb', line 29 def initialize( = DEFAULT_SERVER_OPTIONS_PATH, environment = 'development') self.class.() ENV['RACK_ENV'] = environment # initialise/migrate the db and start cleanup/caching timers DB.start DB.start_timers # ping data is processed in a thread pool Thread.new do while true ping = Server.ping_queue.pop begin ping.call rescue => e puts e.inspect if e.backtrace.is_a?(Array) puts e.backtrace.join("\n") + "\n" end end end end end |
Class Method Details
.load_options(path = DEFAULT_SERVER_OPTIONS_PATH) ⇒ Object
69 70 71 |
# File 'lib/perus/server/server.rb', line 69 def self.(path = DEFAULT_SERVER_OPTIONS_PATH) .load(path, DEFAULT_SERVER_OPTIONS) end |
.options ⇒ Object
65 66 67 |
# File 'lib/perus/server/server.rb', line 65 def self. @options ||= Perus::Options.new end |
.ping_queue ⇒ Object
61 62 63 |
# File 'lib/perus/server/server.rb', line 61 def self.ping_queue @ping_queue ||= Queue.new end |
Instance Method Details
#run ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/perus/server/server.rb', line 53 def run Thin::Server.start( self.class..listen, self.class..port.to_i, App ) end |