我遇到了同样的问题,比如Rails 自定义环境 Resque.enqueue does not create jobs,但那里的解决方案对我不起作用。
我正在使用Resque
几个异步作业。它适用于staging
环境,但由于某种原因它停止在development
环境中工作。
例如,如果我运行以下命令:
$ rails c development
> Resque.enqueue(MyLovelyJob, 1)
没有任何东西排队。我检查 Resque 使用resque-web
如果我在登台上运行它 - 它工作得很好。
$ 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
时钟:bundle exec rake resque:scheduler VERBOSE=1
网络:捆绑 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