Sinatra and Shotgun error

Hi while running Sinatra (default way, ruby my app.rb) I do get output
from the webrick server running
for every request. However I didn’t want to restart server every time
and installed Shotgun gem .When I start with shotgun no output is given,
how can I get that like when I ran it without shotgun.
Also while I tried with the -d option for debug in shotgun I do have
some errors I can’t get my
fingers on.

Exception `LoadError’ at
/Users/robertahlberg/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36

  • cannot load such file – thin
    Exception `LoadError’ at
    /Users/robertahlberg/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:63
  • cannot load such file – thin
    Exception `LoadError’ at
    /Users/robertahlberg/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/handler.rb:41
  • cannot load such file – thin

Other than that it works, and shows pages without errors. I tried
installing thin, then it runs thin instead but still gives the first of
the 3 errors listed above.

Can I just ignore those errors listed when doing shotgun -d ? But I
still would like to see output directly from the webrick as in rails and
when running sinatra with ruby app.rb.

ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

Also one side question: When I installed thin, it started as default for
my sinatra app. I know I can specify server in the source file of my
application. But where do I change it so it start webrick as default
again? Even while having thin installed.

On Jun 19, 2012, at 14:15 , Robert Ahlberg wrote:

Exception `LoadError’ at

/Users/robertahlberg/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36

  • cannot load such file – thin
    Exception `LoadError’ at

/Users/robertahlberg/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:63

  • cannot load such file – thin
    Exception `LoadError’ at

/Users/robertahlberg/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/handler.rb:41

  • cannot load such file – thin

This output is entirely typical of running ruby with -d.

Ah yes it seems you’re right, I get similar output while running various
scripts with the -d thank you!

Then there’s only two problems left =) Have webrick start by default
after thin installation, and get output from the server with shotgun.
Like in rails and when running sinatra with only ruby (without shotgun)

This line
options = {:Port => 9393, :Host => ‘127.0.0.1’, :AccessLog => [], :Path
=> ‘/’}
from the shotgun binary, AccessLog must have something to do with my
problem, cause it’s the access log I want to be verbose and not silent
as is now.

On Jun 19, 2012, at 23:09 , Robert Ahlberg wrote:

Then there’s only two problems left =) Have webrick start by default
after thin installation, and get output from the server with shotgun.
Like in rails and when running sinatra with only ruby (without shotgun)

I suggest you file support tickets with sinatra for those two issues
(separately).

https://github.com/rtomayko/shotgun/issues/39 seems like it already is
an issue, and with a fix for it. But I don’t understand it, rack_env
should be development by default and sure is when Im running. So it
should log properly as it is, if you look at the fix.

But seems like owner of shotgun has abandoned the project, authored a
year ago =/

I used to play with Sinatra a lot, as well as Shotgun and just looked
through an old project. It had code like this:

before do

if using shotgun, create a custom log format

!settings.shotgun || begin
logger.class_eval do
cattr_accessor :format
self.format = <<-HTML
#{Time.now}
#{request.request_method} #{request.fullpath}
Content-Length: #{request.content_length}
Params: #{request.params}
HTML
end
logger.info logger.format
end
end

This was around a year ago so not saying everything will work as is, but
it worked for me then as a sort of hacky solution. Don’t know why i was
overriding the accessor on each request and not just passing in
parameters to the format method, but hey, it was a year ago :slight_smile:

As for running webrick with thin installed, can’t you just do
set :server, ‘webrick’
see
https://github.com/sinatra/sinatra/blob/master/lib/sinatra/base.rb#L1622,
thin gets tried before webrick, but you can customize that with the set
method (can be an array of servers to try in that order, or a string.

Hope it helps,

-Luke