我一直在努力两天,让sidekiq在英雄生产环境上工作.我已经阅读了有关类似问题的所有可用的文档,仍然无法生成一个工作的解决方案,我真的很想帮忙!
在heroku上部署后,我的应用程序崩溃,我收到以下错误堆栈跟踪:
2014-09-23T23:38:40.905093+00:00 app[worker.1]: No such file or directory @ rb_sysopen - /app/tmp/pids/sidekiq.pid 2014-09-23T23:38:40.905122+00:00 app[worker.1]: /app/vendor/bundle/ruby/2.1.0/bin/sidekiq:23:in `<main>' 2014-09-23T23:38:40.905119+00:00 app[worker.1]: /app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/bin/sidekiq:7:in `<top (required)>' 2014-09-23T23:38:40.905117+00:00 app[worker.1]: /app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/cli.rb:347:in `write_pid' 2014-09-23T23:38:40.905115+00:00 app[worker.1]: /app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/cli.rb:347:in `open' 2014-09-23T23:38:40.905121+00:00 app[worker.1]: /app/vendor/bundle/ruby/2.1.0/bin/sidekiq:23:in `load' 2014-09-23T23:38:40.905118+00:00 app[worker.1]: /app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/cli.rb:41:in `parse' 2014-09-23T23:38:40.905114+00:00 app[worker.1]: /app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/cli.rb:347:in `initialize' 2014-09-23T23:38:39.588001+00:00 heroku[worker.1]: State changed from starting to up
首先,sidekiq在我的本地机器上正常工作.我正在使用heroku的REDISTOGO作为redis,在本地制作中,sidekiq已经被正确地指向REDISTOGO并且运行正常.
其次,根据堆栈跟踪,特别是这行没有这样的文件或目录@ rb_sysopen – /app/tmp/pids/sidekiq.pid;它导致我认为,由于某些原因,在heroku上运行时,sidekiq.pid文件不能正确生成.在本地环境中,每当我在app / tmp / pids /目录中启动应用程序时,都会生成sidekiq.pid文件,并且每次分配一个不同的pid号码.我猜,当在heroku上运行时,sidekiq试图从这个文件中读取,但找不到它.
以下是我的Procfile中的内容:
web: bundle exec rails server worker: bundle exec sidekiq -C config/sidekiq.yml
这里是我的config / sidekiq.yml中的内容
--- :verbose: true :pidfile: ./tmp/pids/sidekiq.pid :concurrency: 25 # Set timeout to 8 on Heroku,longer if you manage your own systems. :timeout: 8 :queues: - carrierwave
这里是我的sidekiq.rb的内容
Sidekiq.configure_server do |config| config.redis = { :url => ENV['REDISTOGO_URL'],:namespace => "mynamespece"} end Sidekiq.configure_client do |config| config.redis = { :url => ENV['REDISTOGO_URL'],:namespace => "mynamespece"} end
更新1:
我正在使用carrierwave和carrierwave-backgrounder与sidekiq同步.