我是新手使用sidekiq& redis和我试图让sidekiq在Heroku上运行,但是每次我部署我的Rails 4应用程序时它似乎都会崩溃。我在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
我正在使用RedisToGo添加。以下是我的配置:
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']
我应该注意,我有一个log / sidekiq.log文件。此外,我以前一直在监控日志文件,但现在我不是。我已经仔细检查过他们正在检查我的其他gitrepo。 sidekiq.log文件就在那里......它只是找不到。
答案 0 :(得分:8)
从config.yml中删除pidfile和logfile行。你在Heroku上运行,他们没有任何意义。