Heroku 上的 Resque 无法正常运行
我使用 Resque + RedisToGo 进行后台工作。我在 Heroku 上运行后台任务时遇到问题。这很奇怪,因为我第一次运行后台作业时,它的执行没有任何问题。但是当我再次运行它时,它没有执行。我必须每隔一次运行“heroku restart”才能使后台成功完成......
例如,如果我的 Resque 后台操作中有以下代码:
module EncodeSong
@queue = :encode_song
def self.perform(media_id, s3_file_url)
puts 'foobar'
media = Media.find(media_id)
puts 'media id is supposed to be here'
puts media.id
puts s3_file_url
end
end
在“heroku 控制台”中,我会执行以下操作:
Resque.enqueue(EncodeSong, 26, 'http://actual_bucket_name.s3.amazonaws.com/unencoded/users/1/songs/test.mp3')
在“heroku 控制台”中当我第一次运行上面的代码时,我可以看到4个“puts”。但是第二次运行它,只返回“foobar”。其他“puts”没有显示......
我怀疑它第二次无法运行“media = Media.find(media_id)”。这仅发生在 Heroku 的生产服务器上,在我们的本地开发计算机上,我们没有遇到此问题... .有人知道出了什么问题吗?
PS。我尝试启用 Heroku 日志,但仍然不行我没有得到任何有用的回复。 使用 Resque 设置 Heroku
Im using Resque + RedisToGo for my background jobs. I am having trouble running background tasks on Heroku. Its strange because, the first time I run a background job, it gets executed without any issues. But when I run it again, it doesnt execute. I would have to run "heroku restart', every other time for a background to complete successfully....
For example. If I have the following code in my Resque background action:
module EncodeSong
@queue = :encode_song
def self.perform(media_id, s3_file_url)
puts 'foobar'
media = Media.find(media_id)
puts 'media id is supposed to be here'
puts media.id
puts s3_file_url
end
end
In "heroku console", I do:
Resque.enqueue(EncodeSong, 26, 'http://actual_bucket_name.s3.amazonaws.com/unencoded/users/1/songs/test.mp3')
In "heroku logs", I can see the 4 "puts", when I run the above code for the first time. But running it a second time, only returns 'foobar'. The other "puts" are not displayed.....
I suspect that it is not able to run "media = Media.find(media_id)", the second time around. This is only happening on the production server on Heroku. On our local development machine, we do not experience this problem.... Anyone know what is wrong?
PS. I have tried enabling Heroku logs, but still don't get any useful response. I have followed this tutorial to set up Heroku with Resque
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您的工作失败了(可能您对“media = Media.find”行的看法是正确的)。查看 resque 管理界面。查找失败的作业,您将在那里找到每个失败作业的回溯。
希望这有帮助。
Seems like your job is failing (probably you're right about the 'media = Media.find' line). Look through the resque admin interface. Look for failed jobs, there you'll find the backtrace of each failed job.
Hope this helps.