Search code examples
ruby-on-railsruby-on-rails-4herokuredissidekiq

Error starting sidekiq on Heroku, missing sidekiq.log file crash


I'm new to using sidekiq & redis and am trying to get sidekiq to run on Heroku, but it seems to crash each time I deploy my Rails 4 app. I get this error in Papertrail:

May 03 11:16:37 myapp app/worker.1:  No such file or directory @ rb_sysopen - ./log/sidekiq.log 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/ruby-2.2.0/lib/ruby/2.2.0/logger.rb:636:in `initialize' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/ruby-2.2.0/lib/ruby/2.2.0/logger.rb:636:in `open' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/ruby-2.2.0/lib/ruby/2.2.0/logger.rb:636:in `create_logfile' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/ruby-2.2.0/lib/ruby/2.2.0/logger.rb:630:in `rescue in open_logfile' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/ruby-2.2.0/lib/ruby/2.2.0/logger.rb:627:in `open_logfile' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/ruby-2.2.0/lib/ruby/2.2.0/logger.rb:584:in `initialize' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/ruby-2.2.0/lib/ruby/2.2.0/logger.rb:318:in `new' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/ruby-2.2.0/lib/ruby/2.2.0/logger.rb:318:in `initialize' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/bundle/ruby/2.2.0/gems/sidekiq-3.3.4/lib/sidekiq/logging.rb:31:in `new' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/bundle/ruby/2.2.0/gems/sidekiq-3.3.4/lib/sidekiq/logging.rb:31:in `initialize_logger' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/bundle/ruby/2.2.0/gems/sidekiq-3.3.4/lib/sidekiq/cli.rb:344:in `initialize_logger' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/bundle/ruby/2.2.0/gems/sidekiq-3.3.4/lib/sidekiq/cli.rb:39:in `parse' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/bundle/ruby/2.2.0/gems/sidekiq-3.3.4/bin/sidekiq:7:in `<top (required)>' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/bundle/ruby/2.2.0/bin/sidekiq:23:in `load' 
May 03 11:16:37 myapp app/worker.1:  /app/vendor/bundle/ruby/2.2.0/bin/sidekiq:23:in `<main>' 
May 03 11:16:38 myapp heroku/worker.1:  State changed from up to crashed 
May 03 11:16:38 myapp heroku/worker.1:  Process exited with status 1 

I am using the RedisToGo add on. Here are my configurations:

sidekiq.yaml

---
development:
  :concurrency: 10
production:
  :concurrency: 20

:pidfile: ./tmp/pids/sidekiq.pid
:logfile: ./log/sidekiq.log
:queues:
- default
- mailers
- [high_priority, 2]

Procfile

worker: bundle exec sidekiq -c 2 -v config/sidekiq.yml
web: bundle exec puma -p $PORT

sidekiq.rb

require 'sidekiq'

ENV["REDISTOGO_URL"] ||= "redis://localhost:6379"

Sidekiq.configure_server do |config|
  config.redis = { url: ENV["REDISTOGO_URL"], :size => 4  }

  database_url = ENV['MYAPP_DATABASE_URL']
  if database_url
    ENV['MYAPP_DATABASE_URL'] = "#{database_url}?pool=50"
    ActiveRecord::Base.establish_connection
  end

end


Sidekiq.configure_client do |config|
  config.redis = { url: ENV["REDISTOGO_URL"], :size => 1 }
end

my_var.rb

 ENV['REDISTOGO_URL'] = 'redis:/myredistogourl/'
  ENV['PROVIDER_URL'] = ENV['REDISTOGO_URL']

I should note, I DO have a log/sidekiq.log file. Also, I had been gitignoring log files before, but now I'm not. I've double checked that they are checking into my other gitrepo. The sidekiq.log file is there...it's just not being found.


Solution

  • Remove the pidfile and logfile lines from your config.yml. You're running on Heroku, they don't make any sense.