The docs on Modular vs. Classic style mention that there are some changes to the default settings, and one of these is logging, which is turned off by default.
Adding settings.logging = true
to the top of class Frontend < Sinatra::Base
gives me a log in my terminal window for the localhost:5000 requests.
I don't think the second issue is that it's creating two processes, but rather that it's killing and re-starting the process right before closing the server. This can be solved by following the Sinatra recipe for using EventMachine with Sinatra, which is a little more complicated than what you've done. Here's their code, modified to fit your app:
The new app.rb
:
EM.run do
server = 'thin'
host = '0.0.0.0'
port = ENV['PORT'] || '8181'
web_app = App::Frontend.new
# Start some background tasks here...
EM.add_periodic_timer(1200) do
# Do a repeating task here...
end
dispatch = Rack::Builder.app do
map '/' do
run web_app
end
end
Rack::Server.start({
app: dispatch,
server: server,
Host: host,
Port: port
})
end
(original source, from Sinatra Recipes)
The use of ENV['PORT']
in the app.rb lets you use multiple instances in foreman (e.g., foreman start -p 4000 -c web=2
, which will run services on ports 4000 and 4001). And both of them appear in the log!
Hope that helps.