New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shouldn't the opening example include Sinatra::Application.run!
?
#1507
Comments
@yoLotus Thanks for your report. That is good point. Line 26 in 69956da
In your case, Line 11 in 69956da
In order to avoid the issue quickly, you can do it by setting require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'sinatra', require: 'sinatra'
end
set :app_file, $0
get '/' do
'Hello world!'
end However, this is not understandable. We need to take care the case. |
Hello @namusyaka , thanks for your detailed answer. I didn't know about the I usually use |
@yoLotus Thanks for confirmation. |
Just a side question but I was wondering if it was really necessary to run at_exit { Application.run! if $!.nil? && Application.run? } Only check that Otherwise when I modify the module Sinatra
class Application < Base
# we assume that the first file that requires 'sinatra' is the
# app_file. all other path related options are calculated based
# on this path by default.
set :app_file, caller_files.first || $0
set :expanded_caller_files, caller_files.map{ |f| File.expand_path(f) }
set :run, Proc.new { expanded_caller_files.include?(File.expand_path($0)) }
# ...
end
at_exit { Application.run! if $!.nil? && Application.run? }
end But I am not sure it's the best way to do... |
Hello @namusyaka Just tried your patch by running the example of my first comment of this thread (by removing the Don't know if a test should be add, but if you think it is not necessary, everything seems good on my side. Thanks a lot for the patch! |
It's worth testing, of course. Thanks for confirming. |
Hello,
I tried to run the opening example as written in the first lines of the README but when running
ruby myapp.rb
it silently exit without listening on port4567
.I needed to add
Sinatra::Application.run!
to make it worked:Did I miss something?
The text was updated successfully, but these errors were encountered: