Ruby local Gem acting in Docker container - ruby

As the last resource before I throw all this refactoring away I am asking this question here. There is this strange behaviour I am facing. I am new to Ruby so most likely it is something I am doing wrong.
I extracted some common functionality into a local Gem which works when running the Sinatra App locally (It is a simple Github App).
But when I try running into a Docker container, it would seem to only run the calls to the Gem after I shutdown (Ctrl+c) the application (Logs appear after Sinatra finishes).
To Build the image I am doing the steps below:
FROM ruby:slim-buster
ARG GITHUB_APP_IDENTIFIER
ARG GITHUB_WEBHOOK_SECRET
ARG GITHUB_PRIVATE_KEY
ARG ACCESS_TOKEN
RUN apt update && apt install -y git --no-install-recommends
COPY LineEnding/line_ending.rb LineEnding/Gemfile LineEnding/Gemfile.lock /line_ending/
COPY github_gem/ /github_gem
WORKDIR /github_gem
RUN gem install bundler && bundle install
RUN gem install github_gem-0.1.0.gem
WORKDIR /line_ending
RUN bundle install
ENV GITHUB_APP_IDENTIFIER ${GITHUB_APP_IDENTIFIER}
ENV GITHUB_WEBHOOK_SECRET ${GITHUB_WEBHOOK_SECRET}
ENV GITHUB_PRIVATE_KEY ${GITHUB_PRIVATE_KEY}
ENV ACCESS_TOKEN ${ACCESS_TOKEN}
EXPOSE 3001
CMD ["ruby", "line_ending.rb"]
When running locally, works perfectly, and the logs are like:
As another piece of information, I tried piping the logs in Docker like:
def initialize
docker_stdout = IO.new(IO.sysopen("/proc/1/fd/1", "w"),"w")
#logger = Logger.new(docker_stdout)
#logger.level = Logger::DEBUG
end
It didn't make any difference, both STDOUT and docker_stdout behave in the same manner.
Complete error log:
[2020-11-17 10:20:48] INFO WEBrick 1.6.0
[2020-11-17 10:20:48] INFO ruby 2.7.2 (2020-10-01) [x86_64-linux]
== Sinatra (v2.0.4) has taken the stage on 3001 for development with backup from WEBrick
[2020-11-17 10:20:48] INFO WEBrick::HTTPServer#start: pid=1 port=3001
D, [2020-11-17T10:21:00.306766 #1] DEBUG -- : request
D, [2020-11-17T10:21:00.308179 #1] DEBUG -- : Authenticate app
D, [2020-11-17T10:21:00.308209 #1] DEBUG -- : 2020-11-17 10:21:00.308206249 +0000
D, [2020-11-17T10:21:00.308245 #1] DEBUG -- : 1605608460
D, [2020-11-17T10:21:00.308290 #1] DEBUG -- : 1605609060
D, [2020-11-17T10:21:00.312411 #1] DEBUG -- : Get installation key
WARNING: The preview version of the Integrations API is not yet suitable for production use.
You can avoid this message by supplying an appropriate media type in the 'Accept' request
header.
2020-11-17 10:21:08 - Faraday::ConnectionFailed - Failed to open TCP connection to github.com:443 (getaddrinfo: Temporary failure in name resolution):
/usr/local/lib/ruby/2.7.0/net/http.rb:960:in `initialize'
/usr/local/lib/ruby/2.7.0/net/http.rb:960:in `open'
/usr/local/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
/usr/local/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
/usr/local/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
/usr/local/lib/ruby/2.7.0/net/http.rb:958:in `connect'
/usr/local/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
/usr/local/lib/ruby/2.7.0/net/http.rb:932:in `start'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/adapter/net_http.rb:152:in `request_via_request_method'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/adapter/net_http.rb:137:in `request_with_wrapped_block'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/adapter/net_http.rb:128:in `perform_request'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/adapter/net_http.rb:70:in `block in call'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/adapter.rb:61:in `connection'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/adapter/net_http.rb:68:in `call'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/response.rb:11:in `call'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/response.rb:11:in `call'
/usr/local/bundle/gems/octokit-4.19.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
/usr/local/bundle/gems/octokit-4.19.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/request/retry.rb:148:in `call'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/rack_builder.rb:154:in `build_response'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/connection.rb:492:in `run_request'
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/connection.rb:279:in `post'
/usr/local/bundle/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
/usr/local/bundle/gems/octokit-4.19.0/lib/octokit/connection.rb:156:in `request'
/usr/local/bundle/gems/octokit-4.19.0/lib/octokit/connection.rb:28:in `post'
/usr/local/bundle/gems/octokit-4.19.0/lib/octokit/client/apps.rb:78:in `create_app_installation_access_token'
/usr/local/bundle/gems/github_gem-0.1.0/lib/github_gem.rb:137:in `authenticate_installation'
line_ending.rb:69:in `block in <class:GHAapp>'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1635:in `call'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1635:in `block in compile!'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1040:in `block in process_route'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1038:in `catch'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1038:in `process_route'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:983:in `block in filter!'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:983:in `each'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:983:in `filter!'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1096:in `block in dispatch!'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `block in invoke'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `catch'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `invoke'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1094:in `dispatch!'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:924:in `block in call!'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `block in invoke'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `catch'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `invoke'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:924:in `call!'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:913:in `call'
/usr/local/bundle/gems/rack-protection-2.0.4/lib/rack/protection/xss_header.rb:18:in `call'
/usr/local/bundle/gems/rack-protection-2.0.4/lib/rack/protection/path_traversal.rb:16:in `call'
/usr/local/bundle/gems/rack-protection-2.0.4/lib/rack/protection/json_csrf.rb:26:in `call'
/usr/local/bundle/gems/rack-protection-2.0.4/lib/rack/protection/base.rb:50:in `call'
/usr/local/bundle/gems/rack-protection-2.0.4/lib/rack/protection/base.rb:50:in `call'
/usr/local/bundle/gems/rack-protection-2.0.4/lib/rack/protection/frame_options.rb:31:in `call'
/usr/local/bundle/gems/rack-2.0.6/lib/rack/logger.rb:15:in `call'
/usr/local/bundle/gems/rack-2.0.6/lib/rack/common_logger.rb:33:in `call'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:231:in `call'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:224:in `call'
/usr/local/bundle/gems/rack-2.0.6/lib/rack/head.rb:12:in `call'
/usr/local/bundle/gems/rack-2.0.6/lib/rack/method_override.rb:22:in `call'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/show_exceptions.rb:22:in `call'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:194:in `call'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1957:in `call'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1502:in `block in call'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1729:in `synchronize'
/usr/local/bundle/gems/sinatra-2.0.4/lib/sinatra/base.rb:1502:in `call'
/usr/local/bundle/gems/rack-2.0.6/lib/rack/handler/webrick.rb:86:in `service'
/usr/local/lib/ruby/2.7.0/webrick/httpserver.rb:140:in `service'
/usr/local/lib/ruby/2.7.0/webrick/httpserver.rb:96:in `run'
/usr/local/lib/ruby/2.7.0/webrick/server.rb:307:in `block in start_thread'
16.85.88.12 - - [17/Nov/2020:10:20:59 UTC] "POST /event_handler HTTP/1.1" 500 190501
- -> /event_handler
^C== Sinatra has ended his set (crowd applauds)
[2020-11-17 10:21:10] INFO going to shutdown ...
[2020-11-17 10:21:10] INFO WEBrick::HTTPServer#start done.
[2020-11-17 10:21:10] INFO WEBrick 1.6.0
[2020-11-17 10:21:10] INFO ruby 2.7.2 (2020-10-01) [x86_64-linux]
== Sinatra (v2.0.4) has taken the stage on 3001 for development with backup from WEBrick
[2020-11-17 10:21:10] INFO WEBrick::HTTPServer#start: pid=1 port=3001
^C== Sinatra has ended his set (crowd applauds)
[2020-11-17 10:21:10] INFO going to shutdown ...
[2020-11-17 10:21:10] INFO WEBrick::HTTPServer#start done.
D, [2020-11-17T10:21:00.306932 #1] DEBUG -- : ---- get payload
D, [2020-11-17T10:21:00.307577 #1] DEBUG -- : ---- verify webhook signature
D, [2020-11-17T10:21:00.308133 #1] DEBUG -- : ---- received event check_run
D, [2020-11-17T10:21:00.308160 #1] DEBUG -- : ---- action created
D, [2020-11-17T10:21:00.312187 #1] DEBUG -- : ---- authenticate Client

Related

Ruby Unicorn - Thread Exception

I have a Sinatra Application which has connections to a Cassandra Cluster and to a Postgres. For the Cassandra Connection I'm using the datastax cassandra-driver. As App Server I'm using unicorn.
This is how I open my connection:
configure do
enable :logging
set :show_exceptions, ((ENV['SHOW_EXCEPTIONS'] || 'true') == 'true')
cluster = Cassandra.cluster(
username: ENV['CASSANDRA_USERNAME'],
password: ENV['CASSANDRA_PASSWORD'],
hosts: ENV['CASSANDRA_HOSTS'].split(',')
)
keyspace = 'YYXXXX'
set :session, cluster.connect(keyspace)
Local Everything works (with rackup as dev server), on production i get fatal - no Live threads left. Deadlock?
Do you have a idea whats wrong with my config?
Below you find my stacktrace:
172.31.4.18, 35.156.240.164 - - [23/Jan/2017:20:23:41 +0000] "GET /
HTTP/1.0" 200 1744 0.0071
46.105.28.183 - - [23/Jan/2017:20:23:45 +0000] "GET / HTTP/1.0" 200 1744 0.0066
2017-01-23 20:23:46 - fatal - No live threads left. Deadlock?:
/usr/local/lib/ruby/2.3.0/monitor.rb:111:in `sleep'
/usr/local/lib/ruby/2.3.0/monitor.rb:111:in `wait'
/usr/local/lib/ruby/2.3.0/monitor.rb:111:in `wait'
/usr/local/bundle/gems/cassandra-driver-3.1.0/lib/cassandra/future.rb:616:in `block in get'
/usr/local/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/local/bundle/gems/cassandra-driver-3.1.0/lib/cassandra/future.rb:607:in `get'
/usr/local/bundle/gems/cassandra-driver-3.1.0/lib/cassandra/future.rb:396:in `get'
/usr/local/bundle/gems/cassandra-driver-3.1.0/lib/cassandra/session.rb:123:in `execute'
/code/voucher_cloud.rb:72:in `block in <class:VoucherCloud>'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1610:in `call'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1610:in `block in compile!'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `block (3 levels) in route!'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:994:in `route_eval'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `block (2 levels) in route!'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1015:in `block in process_route'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1013:in `catch'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1013:in `process_route'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:973:in `block in route!'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:972:in `each'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:972:in `route!'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1085:in `block in dispatch!'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `block in invoke'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `catch'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `invoke'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1082:in `dispatch!'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:907:in `block in call!'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `block in invoke'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `catch'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `invoke'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:907:in `call!'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:895:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
/usr/local/bundle/gems/rack-1.6.5/lib/rack/logger.rb:15:in `call'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:212:in `call'
/usr/local/bundle/gems/rack-1.6.5/lib/rack/head.rb:13:in `call'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:182:in `call'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:2013:in `call'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1487:in `block in call'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1787:in `synchronize'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:1487:in `call'
/usr/local/bundle/gems/rack-1.6.5/lib/rack/tempfile_reaper.rb:15:in `call'
/usr/local/bundle/gems/rack-1.6.5/lib/rack/lint.rb:49:in `_call'
/usr/local/bundle/gems/rack-1.6.5/lib/rack/lint.rb:37:in `call'
/usr/local/bundle/gems/rack-1.6.5/lib/rack/showexceptions.rb:24:in `call'
/usr/local/bundle/gems/rack-1.6.5/lib/rack/commonlogger.rb:33:in `call'
/usr/local/bundle/gems/sinatra-1.4.7/lib/sinatra/base.rb:219:in `call'
/usr/local/bundle/gems/rack-1.6.5/lib/rack/chunked.rb:54:in `call'
/usr/local/bundle/gems/rack-1.6.5/lib/rack/content_length.rb:15:in `call'
/usr/local/bundle/gems/unicorn-5.2.0/lib/unicorn/http_server.rb:562:in `process_client'
/usr/local/bundle/gems/unicorn-5.2.0/lib/unicorn/http_server.rb:658:in `worker_loop'
/usr/local/bundle/gems/unicorn-5.2.0/lib/unicorn/http_server.rb:508:in `spawn_missing_workers'
/usr/local/bundle/gems/unicorn-5.2.0/lib/unicorn/http_server.rb:132:in `start'
/usr/local/bundle/gems/unicorn-5.2.0/bin/unicorn:126:in `<top (required)>'
/usr/local/bundle/bin/unicorn:22:in `load'
/usr/local/bundle/bin/unicorn:22:in `<main>'
The DataStax Ruby driver documentation mentions that deadlock can occur when "using a framework, server or runtime that forks and you call Client.connect in the parent process".

Ruby IO Error, not opened for reading

Using OmniAuth for Facebook with Sinatra and Ruby 1.9.3. Getting the IO not opened for reading error during the latter stage of the auth process. Haven't seen much else about this online. If you require any more info please let me know.
Failing on the MultiJson line:
get '/auth/failure' do
content_type 'application/json'
MultiJson.encode(request.env)
end
Error:
IOError at /auth/facebook/callback
not opened for reading
file: encoding.rb location: each line: 256
Detailed error log:
== Sinatra/1.4.4 has taken the stage on 4567 for development with backup from Thin
Thin web server (v1.6.1 codename Death Proof)
Maximum connections set to 1024
Listening on localhost:4567, CTRL+C to stop
SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
This poses a security threat. It is strongly recommended that you
provide a secret to prevent exploits that may be possible from crafted
cookies. This will not be supported in future versions of Rack, and
future versions will even invalidate your existing user cookies.
Called from: /Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:86:in `new'.
127.0.0.1 - - [08/Dec/2013 18:34:03] "GET / HTTP/1.1" 302 - 0.0025
I, [2013-12-08T18:34:03.828713 #927] INFO -- omniauth: (facebook) Request phase initiated.
127.0.0.1 - - [08/Dec/2013 18:34:03] "GET /auth/facebook HTTP/1.1" 302 203 0.0049
I, [2013-12-08T18:34:04.278981 #927] INFO -- omniauth: (facebook) Callback phase initiated.
IOError - not opened for reading:
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:256:in `each'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:256:in `to_a'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:256:in `as_json'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:58:in `block in as_json'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:81:in `check_for_circular_references'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:57:in `as_json'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:296:in `block in as_json'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:296:in `each'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:296:in `map'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:296:in `as_json'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:50:in `block in encode'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:81:in `check_for_circular_references'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:49:in `encode'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/json/encoding.rb:34:in `encode'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/core_ext/object/to_json.rb:16:in `to_json'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/multi_json-1.8.2/lib/multi_json/adapters/json_common.rb:21:in `dump'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/multi_json-1.8.2/lib/multi_json/adapter.rb:24:in `dump'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/multi_json-1.8.2/lib/multi_json.rb:137:in `dump'
app.rb:87:in `block in <main>'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1593:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1593:in `block in compile!'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:957:in `[]'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:957:in `block (3 levels) in route!'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:976:in `route_eval'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:957:in `block (2 levels) in route!'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:997:in `block in process_route'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:995:in `catch'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:995:in `process_route'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:955:in `block in route!'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:954:in `each'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:954:in `route!'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1067:in `block in dispatch!'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `block in invoke'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `catch'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `invoke'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1064:in `dispatch!'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:889:in `block in call!'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `block in invoke'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `catch'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `invoke'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:889:in `call!'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:877:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/omniauth-1.1.4/lib/omniauth/strategy.rb:401:in `call_app!'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/omniauth-1.1.4/lib/omniauth/strategy.rb:363:in `callback_phase'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/omniauth-oauth2-1.0.3/lib/omniauth/strategies/oauth2.rb:65:in `callback_phase'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/omniauth-1.1.4/lib/omniauth/strategy.rb:226:in `callback_call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/omniauth-1.1.4/lib/omniauth/strategy.rb:182:in `call!'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/omniauth-1.1.4/lib/omniauth/strategy.rb:164:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/omniauth-1.1.4/lib/omniauth/builder.rb:49:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-protection-1.5.1/lib/rack/protection/xss_header.rb:18:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-protection-1.5.1/lib/rack/protection/path_traversal.rb:16:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-protection-1.5.1/lib/rack/protection/json_csrf.rb:18:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-protection-1.5.1/lib/rack/protection/base.rb:50:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-protection-1.5.1/lib/rack/protection/base.rb:50:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/logger.rb:15:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/commonlogger.rb:33:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:217:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:210:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/show_exceptions.rb:21:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:180:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:2004:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1469:in `block in call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1778:in `synchronize'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.4.4/lib/sinatra/base.rb:1469:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/thin-1.6.1/lib/thin/connection.rb:82:in `block in pre_process'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/thin-1.6.1/lib/thin/connection.rb:80:in `catch'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/thin-1.6.1/lib/thin/connection.rb:80:in `pre_process'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `call'
/Users/philhudson/.rvm/gems/ruby-1.9.3-p448/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `block in spawn_threadpool'
Turns out a GEM conflict was the issue. I fixed the problem with the code from an indirectly related question that used Rails instead. Please see below:
#fix for JSON gem/activesupport bug. More info: http://stackoverflow.com/questions/683989/how-do-you-deal-with-the-conflict-between-activesupportjson-and-the-json-gem
if defined?(ActiveSupport::JSON)
[Object, Array, FalseClass, Float, Hash, Integer, NilClass, String, TrueClass].each do |klass|
klass.class_eval do
def to_json(*args)
super(args)
end
def as_json(*args)
super(args)
end
end
end
end

Unicorn is not starting after upgrade from gitlab 6.0 to 6.2

I recently update from gitlab 6.0 to 6.2 and got an issue on starting unicorn after:
I, [2013-11-25T15:18:16.934411 #5391] INFO -- : Refreshing Gem list
I, [2013-11-25T15:18:39.929592 #5391] INFO -- : listening on addr=/home/git/gitlab/tmp/sockets/gitlab.socket fd=16
I, [2013-11-25T15:18:39.929976 #5391] INFO -- : listening on addr=0.0.0.0:8080 fd=17
I, [2013-11-25T15:18:39.934823 #5391] INFO -- : master process ready
I, [2013-11-25T15:18:39.954384 #5400] INFO -- : worker=0 ready
I, [2013-11-25T15:18:39.963827 #5403] INFO -- : worker=1 ready
E, [2013-11-26T15:28:03.348742 #5391] ERROR -- : reaped #<Process::Status: pid 5394 SIGKILL (signal 9)> worker=unknown
I, [2013-11-26T15:28:03.549345 #5391] INFO -- : reaped #<Process::Status: pid 5400 exit 0> worker=0
I, [2013-11-26T15:28:03.749781 #5391] INFO -- : reaped #<Process::Status: pid 5403 exit 0> worker=1
I, [2013-11-26T15:28:03.749973 #5391] INFO -- : master complete
I, [2013-11-26T15:58:50.547084 #6212] INFO -- : Refreshing Gem list
/usr/local/lib/ruby/1.9.1/psych.rb:203:in `parse': (<unknown>): mapping values are not allowed in this context at line 51 column 14 (Psych::SyntaxError)
from /usr/local/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'
from /usr/local/lib/ruby/1.9.1/psych.rb:151:in `parse'
from /usr/local/lib/ruby/1.9.1/psych.rb:127:in `load'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/settingslogic-2.0.9/lib/settingslogic.rb:103:in `initialize'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/settingslogic-2.0.9/lib/settingslogic.rb:60:in `new'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/settingslogic-2.0.9/lib/settingslogic.rb:60:in `instance'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/settingslogic-2.0.9/lib/settingslogic.rb:37:in `[]'
from /home/git/gitlab/config/initializers/1_settings.rb:38:in `<top (required)>'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:587:in `each'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:587:in `block in <class:Engine>'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/git/gitlab/config/environment.rb:5:in `<top (required)>'
from config.ru:4:in `require'
from config.ru:4:in `block in <main>'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn.rb:48:in `eval'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn.rb:48:in `block in builder'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/bin/unicorn_rails:139:in `call'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/bin/unicorn_rails:139:in `block in rails_builder'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:722:in `call'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:722:in `build_app!'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:140:in `start'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/bin/unicorn_rails:209:in `<top (required)>'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/bin/unicorn_rails:23:in `load'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/bin/unicorn_rails:23:in `<main>'
What's wrong there?
It's running on a Ubuntu 12.04 and I had an isue during the update with receiving of packages repoted at https://github.com/gitlabhq/gitlabhq/issues/5694. Not sure whether it's related.
The issue was a wrong gitlab.yml file. During merging the changes from 6.2 I put in a wrong indention. Having this fixed, it's running now.

ActiveRecord::RecordNotFound - Couldn't find Location with id=favicon.ico

I'm running a Sinatra app locally and it works fine but I can't deploy the app to heroku or EC2. I get the following in my log (locally) about the favicon.ico. I've added this file to my app but it still give me this:
ActiveRecord::RecordNotFound - Couldn't find Location with id=favicon.ico
Any ideas on how to fix this?
== Sinatra/1.4.2 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:4567, CTRL+C to stop
D, [2013-06-06T20:18:30.470678 #1786] DEBUG -- : Location Load (0.2ms) SELECT "locations".* FROM "locations"
127.0.0.1 - - [06/Jun/2013 20:18:30] "GET / HTTP/1.1" 200 2552 0.0419
D, [2013-06-06T20:18:30.763844 #1786] DEBUG -- : Location Load (0.2ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = ? LIMIT 1 [["id", "favicon.ico"]]
ActiveRecord::RecordNotFound - Couldn't find Location with id=favicon.ico:
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/activerecord- 3.2.13/lib/active_record/relation/finder_methods.rb:343:in `find_one'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:314:in `find_with_ids'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:107:in `find'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/querying.rb:5:in `find'
app.rb:36:in `block in <main>'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1415:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1415:in `block in compile!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:944:in `[]'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:944:in `block (3 levels) in route!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:960:in `route_eval'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:944:in `block (2 levels) in route!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:981:in `block in process_route'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:979:in `catch'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:979:in `process_route'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:943:in `block in route!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:942:in `each'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:942:in `route!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1053:in `block in dispatch!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `block in invoke'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `catch'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `invoke'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1050:in `dispatch!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:878:in `block in call!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `block in invoke'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `catch'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `invoke'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:878:in `call!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:864:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/xss_header.rb:18:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/path_traversal.rb:16:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/json_csrf.rb:18:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/frame_options.rb:31:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.5.2/lib/rack/logger.rb:15:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.5.2/lib/rack/commonlogger.rb:33:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:209:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:202:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/showexceptions.rb:21:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:172:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1947:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1610:in `block in call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1693:in `synchronize'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1610:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/thin-1.5.1/lib/thin/connection.rb:79:in `catch'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/thin-1.5.1/lib/thin/connection.rb:79:in `pre_process'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `block in spawn_threadpool'
Do you have a /:something route that then tries to load a record from the db based on :something. It seems like the browser is asking for /favicon.ico and your app is trying to query the database for a record with id favicon.ico.
Do you have a /:something route, and if so what does it do?

Debugging Sinatra application

I install pry and try to use it.
gem "pry"
require 'pry'
#..........
binding.pry
But there are 3 issues :
I don't know to go to the next string (not to the next break point) or watch the value of a variable. There is no information about it!
there is a lot of different prys! pry-debug, pry, pry-db and so on and so forth. Which one should I use?
It stops there it should. But I don't know yet (and didn't find) how to watch the variable's value or how to go to the next line. And it always gives in a few seconds a kind of an error below:
pry(#)> Error: execution expired
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:600:in `getbyte'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:600:in `readline'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:600:in `block in readline'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:544:in `handle_read_errors'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:589:in `readline'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:369:in `retrieve_line'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:304:in `block in r'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:301:in `loop'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:301:in `r'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:271:in `re'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:251:in `rep'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:231:in `block (3 levels) in repl'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:230:in `loop'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:230:in `block (2 levels) in repl'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:229:in `catch'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:229:in `block in repl'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:228:in `catch'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:228:in `repl'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_class.rb:154:in `start'
/var/lib/gems/1.9.1/gems/pry-0.9.10/lib/pry/core_extensions.rb:22:in `pry'
/home/alex/Documents/ruby/my_projects/controllers/my_controller.rb:24:in `block in '
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `call'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `block in compile!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `[]'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (3 levels) in route!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:851:in `route_eval'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (2 levels) in route!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:872:in `block in process_route'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in `catch'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in `process_route'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:834:in `block in route!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `each'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `route!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:936:in `dispatch!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `block in call!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `block in invoke'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `catch'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `invoke'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `call!'
/home/alex/Documents/ruby/my_projects/app.rb:21:in `block in '
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `call'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `block in compile!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `[]'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (3 levels) in route!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:851:in `route_eval'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (2 levels) in route!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:872:in `block in process_route'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in `catch'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in `process_route'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:834:in `block in route!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `each'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `route!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:936:in `dispatch!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `block in call!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `block in invoke'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `catch'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `invoke'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `call!'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:755:in `call'
/var/lib/gems/1.9.1/gems/rack-flash3-1.0.1/lib/rack/flash.rb:120:in `call'
/var/lib/gems/1.9.1/gems/rack-timeout-0.0.3/lib/rack/timeout.rb:16:in `block in call'
/usr/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
/var/lib/gems/1.9.1/gems/rack-timeout-0.0.3/lib/rack/timeout.rb:16:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
/var/lib/gems/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call'
/var/lib/gems/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb:16:in `call'
/var/lib/gems/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb:17:in `call'
/var/lib/gems/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47:in `call'
/var/lib/gems/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/logger.rb:15:in `call'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:129:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/head.rb:9:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/showexceptions.rb:21:in `call'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:99:in `call'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1389:in `block in call'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1471:in `synchronize'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1389:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:134:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/urlmap.rb:64:in `block in call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `each'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/lint.rb:48:in `_call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/lint.rb:36:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/showexceptions.rb:24:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/commonlogger.rb:20:in `call'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:136:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/chunked.rb:43:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
/var/lib/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/usr/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
pry(#)>
Alright, I install
gem "debugger"
and add the breakpoint
debugger
Nothing happens at all.
Log file is not what I'm looking for. I just want to debug a Sinatra application. How do I do that?
In your Gemfile:
gem "pry"
gem "pry-nav"
Run bundle. Then whenever the script encounters binding.pry, you will have a shell opened. You can see where you are with whereami, you move to the next line with next, continue running the script with continue. If you want to inspect a variable, just type its name.
See pry-nav for more info.
pry-debugger is better. and you need to run sinatra app under Modular style.
I created a repo at github which explains how to use pry to debug.
Here is the repo: https://github.com/hlee/sinatra_debugger_example
Difference between pry-debugger and pry-nav
Pry-debugger
if you check the source code of pry-debugger, you will see:
# pry-debugger.gemspec
# Dependencies
gem.required_ruby_version = '>= 1.9.2'
gem.add_runtime_dependency 'pry', '>= 0.9.10'
gem.add_runtime_dependency 'debugger', '~> 1.3'
gem.add_development_dependency 'pry-remote', '~> 0.1.6'
which means, pry-debugger Only supports MRI 1.9.2 and 1.9.3. Since it reliant on debugger, Pry-debugger will support faster tracing, breakpoints and more.
Pry-nav
on the other hand, here is pry-nav source:
# pry-nav.gemspec
# Dependencies
gem.required_ruby_version = '>= 1.8.7'
gem.add_runtime_dependency 'pry', '~> 0.9.10'
gem.add_development_dependency 'pry-remote', '~> 0.1.6'
which meas, pry-nav is a pure ruby approach not reliant on debugger. will supports 1.8.7, will not supports breakpoints and some other features from debugger.
Breakpoints
break SomeClass#run # Break at the start of `SomeClass#run`.
break Foo#bar if baz? # Break at `Foo#bar` only if `baz?`.
break app/models/user.rb:15 # Break at line 15 in user.rb.
break 14 # Break at line 14 in the current file.
break --condition 4 x > 2 # Change condition on breakpoint #4 to 'x > 2'.
break --condition 3 # Remove the condition on breakpoint #3.
break --delete 5 # Delete breakpoint #5.
break --disable-all # Disable all breakpoints.
break # List all breakpoints. (Same as `breakpoints`)
break --show 2 # Show details about breakpoint #2.
Note
pry-nav and pry-debugger cannot be loaded together.

Resources