ruby-on-rails - Rails 开发环境 Resque.enqueue 不创建作业

标签 ruby-on-rails redis resque

我遇到了同样的问题 Rails custom environment Resque.enqueue does not create jobs ,但那里的解决方案对我不起作用。

我正在为几个异步作业使用 Resque。它在 staging 环境中工作得很好,但由于某种原因它在 development 环境中停止工作。

例如,如果我运行以下命令:

$ rails c development

> Resque.enqueue(MyLovelyJob, 1)

没有排队。我使用 resque-web

检查 Resque

如果我在暂存阶段运行它 - 它工作得很好。

$ rails c staging

> Resque.enqueue(MyLovelyJob, 1)

我已经尝试复制 2 环境,它们似乎使用完全相同的配置(database.yml、config/environment 等),但 development 仍然无法正常工作。

如果我这样做

 > Resque.enqueue(UpdateInstancesData, 2)
 > => true
 
 > Resque.info
 > => {
 >       :pending => 0,
 >     :processed => 0,
 >        :queues => 0,
 >       :workers => 1,
 >       :working => 0,
 >        :failed => 0,
 >       :servers => [
 >       [0] "redis://127.0.0.1:6379/0"
 >   ],
 >   :environment => "development"
 > }

有什么建议可以去哪里调试吗?

我正在通过工头运行应用程序。我的 Procfile 看起来像:

faye: rackup faye.ru -s thin -E production

worker1: bundle exec rake resque:work QUEUE=* VERBOSE=1

worker2: bundle exec rake resque:work QUEUE=* VERBOSE=1

clock: bundle exec rake resque:scheduler VERBOSE=1

web: bundle exec rails s


如前所述,对于 staging,一切正常,工头的日志是:

17:03:42 clock.1       | 2013-06-26 17:03:42 Reloading Schedule
17:03:42 clock.1       | 2013-06-26 17:03:42 Loading Schedule
17:03:42 clock.1       | 2013-06-26 17:03:42 Scheduling logging_test
17:03:42 clock.1       | 2013-06-26 17:03:42 Schedules Loaded
17:03:43 worker2.1     | *** Starting worker ttttt-mbp.local:69573:*
17:03:43 worker2.1     | *** Registered signals
17:03:43 worker2.1     | *** Running before_first_fork hooks
17:03:43 worker1.1     | *** Starting worker ttttt-mbp.local:69572:*
17:03:43 worker1.1     | *** Registered signals
17:03:43 worker2.1     | *** Checking another_queue
17:03:43 worker2.1     | *** Checking anotherqueue
17:03:43 worker2.1     | *** Checking statused
17:03:43 worker2.1     | *** Found job on statused
17:03:43 worker2.1     | *** got: (Job{statused} | LoggingTest | ["57e89a1c1b24ce6866bcf5d0e1c07f01", {}])

17:06:30 clock.1       | 2013-06-26 17:06:30 queueing LoggingTest (logging_test)
17:06:33 worker1.1     | *** Checking another_queue
17:06:33 worker2.1     | *** Checking another_queue
17:06:33 worker1.1     | *** Checking anotherqueue
17:06:33 worker2.1     | *** Checking anotherqueue
17:06:33 worker1.1     | *** Found job on anotherqueue
17:06:33 worker1.1     | *** got: (Job{anotherqueue} | LoggingTest | ["0d976869a945766e0cfeca83e7349305", {}])
17:06:33 worker1.1     | *** resque-1.24.1: Processing anotherqueue since 1372259193 [LoggingTest]
17:06:33 worker1.1     | *** Running before_fork hooks with [(Job{anotherqueue} | LoggingTest | ["0d976869a945766e0cfeca83e7349305", {}])]
17:06:33 worker1.1     | *** resque-1.24.1: Forked 69955 at 1372259193
17:06:33 worker2.1     | *** resque-1.24.1: Forked 69956 at 1372259193
17:06:33 worker1.1     | *** Running after_fork hooks with [(Job{anotherqueue} | LoggingTest | ["0d976869a945766e0cfeca83e7349305", {}])]
17:06:33 worker1.1     | JOB :: LoggingTest
17:06:33 worker1.1     | 55555
17:06:33 worker1.1     | *** done: (Job{anotherqueue} | LoggingTest | ["0d976869a945766e0cfeca83e7349305", {}])

而对于 development 它似乎并没有排队然后找到工作。如果队列中已有作业(暂存环境中遗留的待处理作业),则开发工作人员不会处理它。

17:01:23 clock.1       | 2013-06-26 17:01:23 Reloading Schedule
17:01:23 clock.1       | 2013-06-26 17:01:23 Loading Schedule
17:01:23 clock.1       | 2013-06-26 17:01:23 Scheduling logging_test
17:01:23 clock.1       | 2013-06-26 17:01:23 Scheduling update_instances_data
17:01:23 clock.1       | 2013-06-26 17:01:23 Schedules Loaded

17:03:10 clock.1       | 2013-06-26 17:03:10 queueing LoggingTest (logging_test)
17:03:14 worker1.1     | *** Checking another_queue
17:03:14 worker2.1     | *** Checking another_queue
17:03:14 worker1.1     | *** Checking anotherqueue
17:03:14 worker2.1     | *** Checking anotherqueue
17:03:14 worker1.1     | *** Checking statused
17:03:14 worker2.1     | *** Checking statused

最佳答案

问题原来是我的 Gemfile 中的 :development 组也有 gem 'resque_spec'。显然这是一件非常错误的事情......

关于ruby-on-rails - Rails 开发环境 Resque.enqueue 不创建作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17299726/

相关文章:

redis - Spark : How to send arguments to Spark foreach function

ruby - 如何输出 resque-status 的完成百分比?

ruby-on-rails - 即使在生产模式下从服务器运行,Resque 也在写入开发数据库

mysql - 仅通过 resque-scheduler 调用 SQL 查询才会发生 ActiveRecord::StatementInvalid 错误

ruby-on-rails - Rails - 生产模式中的错误

ruby-on-rails - 在Ruby中使用fakeweb或webmock模拟RestClient::GatewayTimeout?

javascript - Rails 5,Gmaps4Rails-设置

ruby-on-rails - Nginx 到 Unicorn 的反向代理 - nginx 配置不正确?

node.js - 对于 Node/Mongo/NginX,哪种缓存方法最快/最轻?

postgresql - Key - 支持按值搜索的值存储