I'm trying to integrate a basic 'hello world' jruby sinatra application with sinatra-synchrony and keep running into errors.
app.rb:
require 'sinatra/synchrony'
class App < Sinatra::Base
register Sinatra::Synchrony
get '/' do
'Hello world!'
end
end
config.ru:
require 'sinatra'
require 'app.rb'
run App
I've tried running this on a few different web servers and get varying errors to do with threads or memory leaks.
Synchrony libraries for Ruby are designed around using Fibers in event loops a la Eventmachine. For this particular case, you should consider using MRI and Goliath.io as your rack server.
However, Jruby is growing by leaps and bounds. I've been using it for last few months and avoiding the event loop paradigm altogether. Try removing the Synchrony library from your example and running it using puma.io.
Keep in mind the JVM takes a bit to "warm up". Hit it a few thousand times to optimize speed.