Sinatra: Sinatra requires CTRL+C twice to shutdown

Created on 16 Mar 2010  路  5Comments  路  Source: sinatra/sinatra

When I ran a small sinatra app, I have to press CTRL+C twice to get it to shutdown.

== Sinatra/1.0.b has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.2.7 codename No Hup)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:4567, CTRL+C to stop
^C>> Stopping ...

== Sinatra has ended his set (crowd applauds)
== Sinatra/1.0.b has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.2.7 codename No Hup)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:4567, CTRL+C to stop
^C>> Stopping ...

== Sinatra has ended his set (crowd applauds)

I'm currently running:

ubuntu 9.10 (karmic)
rubygems 1.3.6
ruby 1.9.1p376 (2009-12-07 revision 26041) [i486-linux]
sinatra 1.0.b
thin 1.2.7

Most helpful comment

It's because I imported sinatra, instead of sinatra/base

All 5 comments

Happens for me when starting a class style application with Application.run in the config.ru, for example.

This used to happen to me before under Cygwin. Definitely has to do with how you start the application and the content of your rackup file. What I do is:

yourapp.rb
class App < Sinatra:Base
whatev..
end

config.ru
require 'rubygems'
require 'yourapp.rb'
run App

and finally, start the app using a batch file or from your shell prompt:

rackup -s thin config.ru

I couldn't reproduce on 1.0. Please re-open if this is still an issue. Thanks

I'm getting this issue. My code can be simplified down to this, and still produces the issue:

require 'sinatra'

class MyServer < Sinatra::Base
  get '/test' do
    'Hello world!'
  end

  run! if app_file == $0
end

I'm running in the terminal with ruby my_server.rb. If I remove the run line, then it only requires ctrl+c once to shutdown, but the endpoint doesn't get called, instead displaying this error:

[28/May/2016:20:37:15 +0100] "GET /test HTTP/1.1" 404 466 0.0005

It's because I imported sinatra, instead of sinatra/base

Was this page helpful?
0 / 5 - 0 ratings

Related issues

b264 picture b264  路  10Comments

iguchi1124 picture iguchi1124  路  10Comments

ibnesayeed picture ibnesayeed  路  15Comments

DannyBen picture DannyBen  路  17Comments

sushant12 picture sushant12  路  16Comments