香港专业教育学院一直试图让resoku与heroku合作.我可以成功地让它在开发模式下工作,但是当我尝试推送到heroku时我得到了
Errno::ECONNREFUSED (Connection refused - Unable to connect to Redis on 127.0.0.1:6379):
Run Code Online (Sandbox Code Playgroud)
然后阅读并关注http://blog.redistogo.com/2010/07/26/resque-with-redis-to-go/
我把网站上列出的配置但出现以下错误
SocketError (getaddrinfo: nodename nor servname provided, or not known):
Run Code Online (Sandbox Code Playgroud)
我输入了我的初始化器/ resque.rb
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
ENV["redis://redistogo:11111111111111111@lab.redistogo.com:9254/"] ||= "redis://heroku_username:heroku_password@host:9254/"
uri = URI.parse(ENV["redis://redistogo:1111111111111111@lab.redistogo.com:9254/"])
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Run Code Online (Sandbox Code Playgroud)
但它会抛出上面提到的错误.在我的开发模式现在,我也得到了错误.
我尝试使用我的heroku用户名(即时通讯使用heroku中的add),将我的密码输入heroku,并将端口更改为9254.但是我现在不断收到套接字错误.我究竟做错了什么?
帮助将不胜感激.谢谢
UPDATE.
@kevin
我试过了
uri = URI.parse(ENV["my_url_string"] || "redis://localhost:9254/" )
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Run Code Online (Sandbox Code Playgroud)
在初始化程序/ redis.rb中,但我得到以下错误
Errno::ECONNREFUSED (Connection refused - Unable to …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个测试resque-retry的重试功能的规范,我似乎无法让测试正确地命中binding.pry.有没有办法使用rspec 3测试此功能,以便我可以验证它们是否按预期运行?
这是一个请求规范,我试图通过fixtures模拟一个实时请求,但无论我尝试什么,我似乎无法得到重试的工作.
gem 'resque', require: 'resque/server'
gem 'resque-web', require: 'resque_web'
gem 'resque-scheduler'
gem 'resque-retry'
gem 'resque-lock-timeout'
Run Code Online (Sandbox Code Playgroud)
我正在使用resque_rspec,并尝试此测试策略.
部分规格
it 'retries it' do
stub_request(:any, /.*api.bigcartel.*/).to_return(body: '{}', status: 200)
@order_shipped_json['order']['originator_id'] = @provider_order
post "/hook/shops/#{@shop.id}", @order_shipped_json.to_json, format: :json
ResqueSpec.perform_all(queue_name)
???
end
Run Code Online (Sandbox Code Playgroud)
队列工作
class QueueHook
extend Resque::Plugins::LockTimeout
extend Resque::Plugins::Retry
extend QueueLock
extend QueueLogger
@queue = AppSettings.queues[:hook_queue_name].to_sym
@lock_timeout = 600
@retry_exceptions = [QueueError::LockFailed]
@retry_limit = 600
@retry_delay = 1
class << self
def perform(web_hook_payload_id, _whiplash_customer_id)
ActiveRecord::Base.clear_active_connections!
@web_hook_payload = WebHookPayload.find(web_hook_payload_id)
klass_constructor …Run Code Online (Sandbox Code Playgroud) 我正在尝试将应用程序从Rails 3.0.3移植到Rails 3.1rc ......在配置方面,我认为我没有错过任何东西.该过程在Rails 3.0.X中完美运行,而在3.1rc中则不然.
在控制台中,我做:
Resque.enqueue(EncodeSong, Song.find(20).id, Song.find(20).unencoded_url)
Run Code Online (Sandbox Code Playgroud)
到目前为止一切都有效.Resque-web报告没有失败的作业.而且,我从模块EncodeSong获得了两个'puts'.
但是,再次运行Resque.enqueue(EncodeSong,Song.find(20).id,Song.find(20).unencoded_url)将在resque-web(下面)中返回以下错误.为了使错误消失,我必须关闭正在运行的进程:QUEUE =*rake environment resque:工作并在控制台窗口中重新运行它.但是在第一次尝试Resque.enqueue()之后问题又回来了.
Class
EncodeSong
Arguments
20
"https://bucket_name.s3.amazonaws.com/unencoded/users/1/songs/test.mp3"
Exception
PGError
Error
server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:272:in `exec'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:272:in `block in clear_cache!'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:271:in `each_value'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:271:in `clear_cache!'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:299:in `disconnect!'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:191:in `block in disconnect!'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `each'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `disconnect!'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activesupport-3.1.0.rc1/lib/active_support/core_ext/module/synchronization.rb:35:in `block in disconnect_with_synchronization!'
/Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activesupport-3.1.0.rc1/lib/active_support/core_ext/module/synchronization.rb:34:in `disconnect_with_synchronization!'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:407:in `remove_connection'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_specification.rb:116:in `remove_connection'
/Users/Chris/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_specification.rb:79:in `establish_connection' …Run Code Online (Sandbox Code Playgroud) 我不知道Postgres能够理解这个消息.
PG::Error: SSL error: decryption failed or bad record mac : SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"users"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum
Run Code Online (Sandbox Code Playgroud)
这是来自resque后端的callstack
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1139:in `async_exec'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1139:in `exec_no_cache'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in `block in exec_query'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:662:in `exec_query'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1264:in `column_definitions'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:858:in `columns'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `yield'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `default'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `columns'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:237:in …Run Code Online (Sandbox Code Playgroud) 嗨,是否有可能在开发过程中同时运行多个Resque工作人员?我找到了这段代码,但不确定它是否会起作用以及如何...
到目前为止,我正在使用该标准
bundle exec env rake resque:work QUEUE='*'
redis-server /usr/local/etc/redis.conf
Run Code Online (Sandbox Code Playgroud) 我正和一位朋友一起开展一个项目,我们一直在使用Resque来处理来自rails应用程序内部数据输入的各种命令.
我们一直在搞乱使用Sidekiq的想法,因为它是多线程的,不会是内存占用,也不需要为每个工作者启动ruby env.
我希望能够从实时使用Resque和Sidekiq的人那里收集一些想法和意见,并解释其中的差异.
那么,Sidekiq对Resque的利弊是什么?
我正在构建一个允许同时上传大量照片的应用程序,并想知道解决此问题的最佳设置.
这是我到目前为止使用的:
我想允许用户能够将大量图像拖放到页面上,然后在后台进行上传时导航到其他页面.我还想在完成上传时显示图片.我不希望这个过程锁定Heroku dynos,所以我可能需要将工作转移到后台工作,但我不确定该用于我的情况.
这类应用程序的最佳设置是什么?我应该使用什么背景工人宝石?Cloudinary是个好主意吗?
ruby-on-rails delayed-job resque carrierwave jquery-file-upload
我正在努力了解如何通过上帝来监视resvis- trai的resvis-ci,以便通过上帝停止resque手表不会留下陈旧的工人进程.
在下面我说的是工作进程,而不是分叉的作业子进程(即队列一直是空的).
当我像这样手动启动resque worker时:
$ QUEUE=builds rake resque:work
Run Code Online (Sandbox Code Playgroud)
我会得到一个过程:
$ ps x | grep resque
7041 s001 S+ 0:05.04 resque-1.13.0: Waiting for builds
Run Code Online (Sandbox Code Playgroud)
一旦我停止工作任务,这个过程就会消失.
但是,当我与上帝开始相同的事情(确切的配置在这里,基本上与resque/god示例相同)就像这样......
$ RAILS_ENV=development god -c config/resque.god -D
I [2011-03-27 22:49:15] INFO: Loading config/resque.god
I [2011-03-27 22:49:15] INFO: Syslog enabled.
I [2011-03-27 22:49:15] INFO: Using pid file directory: /Volumes/Users/sven/.god/pids
I [2011-03-27 22:49:15] INFO: Started on drbunix:///tmp/god.17165.sock
I [2011-03-27 22:49:15] INFO: resque-0 move 'unmonitored' to 'init'
I [2011-03-27 22:49:15] INFO: …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过Resque发送Devise电子邮件.
通过Resque发送普通电子邮件就好了.并且Devise电子邮件发送得很好,但不会通过Resque发送电子邮件.我得到"找不到有效的映射",这意味着我的帮助程序覆盖不会被拾取.
我正在关注这个http://shaker.4-dogs.biz/2011/08/06/using-resque-to-send-mail-for-devise/
奇怪的是,调试它我正在使用Devise的本地副本,并在Devise中的'initialize_from_record'中添加断点,当我仅使用Devise时会受到攻击.但是当我通过resque发送Devise电子邮件时,断点不会受到影响:
class ResqueMailer < Devise::Mailer
include Resque::Mailer
end
config.mailer = "ResqueMailer"
Run Code Online (Sandbox Code Playgroud)
而resque则显示一个打包的gem路径,而不是我的本地源,例如:
/Users/mm/.rvm/gems/ruby-1.9.2-p290@evergreen/gems/devise-1.4.9/lib/devise/mailers/helpers.rb:20:in `devise_mail'
Run Code Online (Sandbox Code Playgroud)
知道为什么它不使用我的本地宝石源和/或如何让Resque发送我的Devise电子邮件?
这是我的情景:
更新AR对象后,它会使用Resque触发一堆后台作业.在我的规格中,我正在嘲笑对Resque#enqueue的调用,其中包含以下内容:
it 'should be published' do
# I need to setup these mocks in many places where I want to mock a specific call to Resque, otherwise it fails
Resque.should_receive(:enqueue).with(NotInterestedJob1, anything)
Resque.should_receive(:enqueue).with(NotInterestedJob2, anything)
Resque.should_receive(:enqueue).with(NotInterestedJob3, anything)
# I'm only interested in mocking this Resque call.
Resque.should_receive(:enqueue).with(PublishJob, anything)
end
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我需要模拟所有其他调用Resque #enqueue每次我想模拟一个特定的调用,有没有办法只模拟自定义调用并忽略其他调用不同的参数?
提前致谢 ;)
resque ×10
ruby ×5
redis ×2
rspec ×2
background ×1
carrierwave ×1
delayed-job ×1
devise ×1
god ×1
heroku ×1
job-queue ×1
mocking ×1
postgresql ×1
resque-retry ×1
sidekiq ×1