Heroku 上的 Ruby 守护进程

3
我正在尝试在Heroku上执行一个无框架的Ruby守护进程应用程序,但在尝试执行worker后它会崩溃。
heroku[worker.1]: State changed from crashed to starting
heroku[worker.1]: Starting process with command `bundle exec rake twitter:start`
heroku[worker.1]: State changed from starting to up
heroku[worker.1]: Process exited with status 0
heroku[worker.1]: State changed from up to crashed

这个应用程序基本上通过一堆API收集数据,并将其保存在远程MongoHQ实例中。

rake任务包括:

dir_path = File.expand_path('../', __FILE__)

namespace :twitter do
  desc 'Start Twitter daemon'
  task :start do
    exec "#{dir_path}/bin/autana start"
  end

  ...
end

Procfile非常简单:worker: bundle exec rake twitter:start

执行守护程序的代码如下:

#!/usr/bin/env ruby
require 'daemons'
require File.expand_path('../../lib/autana', __FILE__)

Daemons.run_proc('autana', multiple: true, no_pidfiles: true) do
  client = Autana::Client::Twitter.new
  client.collect
end

有什么想法吗?

为什么不在你的rake调用中添加标志以获取详细输出 - 这可能有助于其他人帮助你。 - Jon Mountjoy
2个回答

0

你能动态运行它吗?

heroku run rake twitter:start

是的,但当您退出终端时,rake任务将结束。 - user1515295

0

所以,这是一个MongoDB错误。数据没有正确关联。进入控制台后,更改了文档,一切都按预期工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接