lib/perus/server/server.rb in perus-0.1.13 vs lib/perus/server/server.rb in perus-0.1.14
- old
+ new
@@ -1,6 +1,6 @@
-require 'concurrent'
+require 'thread'
require 'thin'
DEFAULT_SERVER_OPTIONS = {
'__anonymous__' => {
'uploads_dir' => './uploads',
@@ -23,10 +23,25 @@
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
def run
Thin::Server.start(
self.class.options.listen,
@@ -34,19 +49,10 @@
App
)
end
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
-
- def self.shutdown
- @ping_queue.shutdown
+ @ping_queue ||= Queue.new
end
def self.options
@options ||= Perus::Options.new
end