Class: Perus::Server::Server
- Inherits:
-
Object
- Object
- Perus::Server::Server
- Defined in:
- lib/perus/server/server.rb
Class Method Summary collapse
- .load_options(path = DEFAULT_SERVER_OPTIONS_PATH) ⇒ Object
- .options ⇒ Object
- .ping_queue ⇒ Object
- .shutdown ⇒ Object
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.
21 22 23 24 25 26 27 28 |
# File 'lib/perus/server/server.rb', line 21 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 end |
Class Method Details
.load_options(path = DEFAULT_SERVER_OPTIONS_PATH) ⇒ Object
55 56 57 |
# File 'lib/perus/server/server.rb', line 55 def self.(path = DEFAULT_SERVER_OPTIONS_PATH) .load(path, DEFAULT_SERVER_OPTIONS) end |
.options ⇒ Object
51 52 53 |
# File 'lib/perus/server/server.rb', line 51 def self. @options ||= Perus::Options.new end |
.ping_queue ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/perus/server/server.rb', line 38 def self.ping_queue # ping data is processed in a thread pool @ping_queue ||= Concurrent::ThreadPoolExecutor.new( min_threads: 2, max_threads: 2, max_queue: 0 ) end |
.shutdown ⇒ Object
47 48 49 |
# File 'lib/perus/server/server.rb', line 47 def self.shutdown @ping_queue.shutdown end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/perus/server/server.rb', line 30 def run Thin::Server.start( self.class..listen, self.class..port.to_i, App ) end |