Sidekiq: /sidekiq Redirects to RoutingError

Created on 29 Apr 2012  路  16Comments  路  Source: mperham/sidekiq

In my routes.rb:

require 'sidekiq/web'
  mount Sidekiq::Web => '/sidekiq'

When attempting to reach /sidekiq I get a no route found error. Using thin+rails3.2+ruby1.9.3. I can see it actually is running the redirect, but then for some reason just not reaching the controller from there.

Started GET "/sidekiq" for 127.0.0.1 at 2012-04-29 01:52:03 -0700


Started GET "/sidekiq/" for 127.0.0.1 at 2012-04-29 01:52:03 -0700

ActionController::RoutingError (No route matches [GET] "/sidekiq"):
  actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
  quiet_assets (1.0.0) lib/quiet_assets.rb:20:in `call_with_quiet_assets'
  actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/static.rb:61:in `call'
  railties (3.2.2) lib/rails/engine.rb:479:in `call'
  railties (3.2.2) lib/rails/application.rb:220:in `call'
  rack (1.4.1) lib/rack/content_length.rb:14:in `call'
  railties (3.2.2) lib/rails/rack/log_tailer.rb:14:in `call'
  thin (1.2.11) lib/thin/connection.rb:84:in `block in pre_process'
  thin (1.2.11) lib/thin/connection.rb:82:in `catch'
  thin (1.2.11) lib/thin/connection.rb:82:in `pre_process'
  thin (1.2.11) lib/thin/connection.rb:57:in `process'
  thin (1.2.11) lib/thin/connection.rb:42:in `receive_data'
  eventmachine (0.12.10) lib/eventmachine.rb:256:in `run_machine'
  eventmachine (0.12.10) lib/eventmachine.rb:256:in `run'
  thin (1.2.11) lib/thin/backends/base.rb:61:in `start'
  thin (1.2.11) lib/thin/server.rb:159:in `start'
  rack (1.4.1) lib/rack/handler/thin.rb:13:in `run'
  rack (1.4.1) lib/rack/server.rb:265:in `start'
  railties (3.2.2) lib/rails/commands/server.rb:70:in `start'
  railties (3.2.2) lib/rails/commands.rb:55:in `block in <top (required)>'
  railties (3.2.2) lib/rails/commands.rb:50:in `tap'
  railties (3.2.2) lib/rails/commands.rb:50:in `<top (required)>'
  script/rails:6:in `require'
  script/rails:6:in `<main>'

Most helpful comment

  require 'sidekiq/web'
  authenticate :user, lambda { |u| u.superuser? } do
    mount Sidekiq::Web, at: '/sidekiq'
  end

This happened to me when my user didn't pass the authenticate code above: u.superuser?. This might help people understand what's happening for them even though I don't think it's the same issue.

All 16 comments

That's pretty weird that it would resolve /sidekiq and then immediately not resolve /sidekiq. I'm stumped.

My rake:routes looks fine....

sidekiq_web        /sidekiq                          Sidekiq::Web

I tried removing my other routes, no luck, going to try removing other gems...

Edit: no luck removing gems.

I know this sounds crazy but does it work if you just directly request "/sidekiq/"?

Ah ok, so tried it on a fresh rails app and it works...

Haha no it does not, same error as above but without the redirect.

Edit: Not really sure... tried removing all libraries, routes, gems, config files, and booting from webbrick and still getting it.

Did you add the slim and sass gems as the Monitoring page notes?

Yes, have them both. Still poking around, emptying application controller was no help.

Tried removing this from web.rb:

return [301, { 'Location' => "#{env['SCRIPT_NAME']}/" }, ['redirecting']] if env['SCRIPT_NAME'] == env['REQUEST_PATH']

Now it doesn't redirect, but still return the error from either url.

Really unsure here as to whats happening.. something with Sinatra is my best guess. Anything I could try out in the console to help figure it out?

Not sure what else to say here. Plenty of people are using the web UI successfully so it must be something in your environment but I'm out for ideas to debug. I even tried using thin locally to see if that was a problem:

=> Booting Thin
=> Rails 3.2.2 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop


Started GET "/sidekiq/" for 127.0.0.1 at 2012-05-02 20:27:44 -0700


Started GET "/sidekiq/assets/application.css" for 127.0.0.1 at 2012-05-02 20:27:44 -0700


Started GET "/sidekiq/assets/application.js" for 127.0.0.1 at 2012-05-02 20:27:44 -0700

Works fine.

this can be if you added constraints and don't pass them

A clue... I had a similar issue and was facing at the same time erractic issues with the Redis connection: in some cases, Redis was not responding (connection timeout). In that situation (e.g. sidekiq web well configured and Redis not reachable), the sidekiq monitoring interface was not available and logs were showing 'No route matches [GET] "/sidekiq"'.

If it can help...

I have the same issue and was related with the gem 'rails-translate-routes'. When I removed it from the router, it all worked again. I'll try to find a solution.

Same problem here, this time related with the gem 'route_translator', similar to yours @danigb. I'll try to find a solution as well.

Any progress on this issue?

I'm getting:

17:33:48 web.1    | I, [2014-01-21T17:33:48.140001 #1241]  INFO -- : Started GET "/sidekiq" for 127.0.0.1 at 2014-01-21 17:33:48 +1100
17:33:48 web.1    | F, [2014-01-21T17:33:48.400644 #1241] FATAL -- : 
17:33:48 web.1    | ActionController::RoutingError (No route matches [GET] "/sidekiq"):

I'm switched to mini_magick and PG::Connection.isthreadsafe returns true. I'm not using any of the gems mentioned above. There is no mention of trouble connecting to Redis in my logs. I've not added any constraints to the route.

I've tried disabling various gems as well as removing the Profile and unicorn refs.

routes.rb:

Testivate::Application.routes.draw do
  require 'sidekiq/web'
  mount Sidekiq::Web, at: "/sidekiq"

  # match "/delayed_job" => DelayedJobWeb, :anchor => false

  post "houdini/Survey/:id/postbacks" => "surveys#receive"
  post "versions/:id/revert" => "versions#revert", :as => "revert_version"
  root :to => 'high_voltage/pages#show', :id => 'home'

  resources :categories
  resources :inputs

  resources :users
  resources :user_sessions
  resources :roles
  resources :assignments


  resources :orders

  resource :account, :controller => "users", :as => :account
  match 'login' => 'user_sessions#new', :as => 'login', :via => [:get, :post]
  match 'logout' => 'user_sessions#destroy', :as => 'logout', :via => [:get, :post]

  resources :elements
  resources :standards
  resources :pictures

  resources :postbacks do
    member do
      post :receive
    end
    collection do
      get :stray
      get :complete
      get :incomplete
    end
  end
  get '/postbacks', to: redirect('/postbacks/complete')

  resources :products do
    resources :tags, :only => :show
    member do
       get :investigate
       get :spreadsheet, :defaults => {:format => 'xls'} 
    end
    resources :questions do
      collection do 
        get :instructionless
        get :fieldless
        get :footnoteless
        get :halfmade
        get :oddscores
      end
      member do
        get :activate
        get :deactivate
        get :add
        get :deadd
      end
      resources :fields
    end
   end

  resources :references do
     resources :footnotes, :except => [:index]
  end
  resources :footnotes, :only => [:index]
  resources :veracities

  resource :search, :only => [:show]

  resources :reviews do
    resources :batteries, :only => [:show]
    member do
      get :print
      get :ready
      get :turkit
      get :feedback
      get :waiting
      get :asked
      get :noinput
      get :clearna
      get :resend
      get :pdf
      get :slides
    end
    resources :competitors do
      member do
         get :audit
      end
    end
  end

  resources :surveys do
    resources :screenshots do
      member do
        get :select
        get :deselect
      end
    end
    member do
      post :receive
      get :normalise
      get :bugfree
    end
  end

  resources :competitors do
    resources :surveys, :only => [:index, :show, :edit, :update] do
      member do
        get :turkit
      end
      resources :results do
        member do
          get :select
          get :deselect
        end
      end
    end
  end

end

gemfile:

ruby "2.0.0"
source "https://rubygems.org"

gem "rails", "4.0.2"

gem "protected_attributes"

gem 'jquery-rails'
gem 'jquery-rails-google-cdn'
gem 'jquery-ui-rails'
gem 'jquery-ui-rails-google-cdn'


gem "rails_serve_static_assets"
gem "activesupport"
gem "actionmailer"
gem "mini_magick", :require => false
gem "mail"
gem "chronic"
gem "railties"
gem "compass"
gem "pg"
gem "sass"
gem "sass-rails"
gem "haml"
gem "haml-rails"
gem "susy"
gem "google-analytics-rails"
gem "declarative_authorization"
gem "authlogic"
gem "simple_form"
gem "country-select"
gem "rails3-generators"
gem "hirb"
gem "redis"
gem "RedCloth"
gem "friendly_id", '~> 5.0.0'
gem "high_voltage"
gem "validatious"
gem "houdini"
gem "html5shiv-rails"
gem "normalize-rails"
gem "unicorn"
gem "paperclip"
gem "aws-sdk"
gem "tinymce-rails"
gem "paper_trail"
gem "foreman"
gem "pry-remote"
gem "gruff"
gem "acts-as-taggable-on"
gem "pg_search"



gem "sidekiq"
# gem "autoscaler"
gem 'sinatra', require: false
gem 'slim'

gem "nokogiri"
gem "delayed_paperclip", :git => "git://github.com/jrgifford/delayed_paperclip.git"
gem "figaro"
gem "httparty"
gem "will_paginate"
gem "render_anywhere", :require => false
gem "doc_raptor"
gem "numbers_and_words"
gem "memcachier"
gem "dalli"
gem "googl"
gem "colorbox-rails"
gem "newrelic_rpm"
gem "site_meta"
gem "easystats"

gem 'rails_12factor', :group => :production


group :test do
  gem "capybara"
  gem "database_cleaner"
  gem "factory_girl_rails"
  gem "launchy"
  gem "respec"
end

group :test, :development do
  gem "rspec-rails"
  gem "parallel_tests"
  gem "zeus-parallel_tests"
  gem "better_errors"
  gem "binding_of_caller"
end

group :development do
  gem "taps"
  gem "pry-rails"
  gem "pry-rescue"
  gem "pry-stack_explorer"
  gem "pry-debugger"
end

group :assets do
  gem "coffee-rails"
  gem "compass-rails"
  gem "compass-susy-plugin"
  gem "fancy-buttons"
  gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
  gem "uglifier"
end

Procfile:

web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker: bundle exec sidekiq -c 5 -v

# worker:  bundle exec rake jobs:work
# before_fork do |server, worker|
#    @sidekiq_pid ||= spawn("bundle exec sidekiq -c 2")
# end

Unicorn.rb:

# config/unicorn.rb
worker_processes 3
timeout 360
preload_app true

before_fork do |server, worker|

  Signal.trap 'TERM' do
    puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
    Process.kill 'QUIT', Process.pid
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!
end

after_fork do |server, worker|

  Signal.trap 'TERM' do
    puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end

For what it's worth...
I had in my gem file:

group :production do
  gem 'dalli'                   # memcached
  gem 'memcachier'              # heroku add-on for auto config of dalli
  gem 'unicorn'
  gem 'rails_12factor'          # https://devcenter.heroku.com/articles/rails4
end

I commented out gem 'unicorn' and it started working... but obviously not necessarily a "fix" per say but wanted to share this finding for now.

  require 'sidekiq/web'
  authenticate :user, lambda { |u| u.superuser? } do
    mount Sidekiq::Web, at: '/sidekiq'
  end

This happened to me when my user didn't pass the authenticate code above: u.superuser?. This might help people understand what's happening for them even though I don't think it's the same issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajcybage picture rajcybage  路  3Comments

bartimaeus picture bartimaeus  路  3Comments

jlecour picture jlecour  路  4Comments

smanolloff picture smanolloff  路  3Comments

homanchou picture homanchou  路  3Comments