我在Sinatra应用程序中内置了一个相当简单的Tweetstream侦听器,我正尝试在Heroku上运行它。它启动并运行良好,但大约一分钟后,我得到以下错误:
2012-12-04T06:23:31+00:00 heroku[web.1]: Stopping process with SIGKILL
2012-12-04T06:23:31+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch基本上,下面是我正在运行的:
require 'sinatra'
client = TwitterListener.new
puts "starting Twitter listener..."
client.restart
require 'tweetstream'
class TwitterListener
def initialize
@client = TweetStream::Client.new
...
@events = Events.new
end
def restart
...
@client.follow(users) do |status|
@events.mention_artist?(status, artists)
@events.retweet_artist?(status, artists)
end
end
end它正在启动流监听器,如果我的tweet足够快,它就会把它接起来,但Heroku似乎在tweetstream循环期间超时了。我该如何解决这个问题呢?
发布于 2012-12-06 07:50:11
所以我必须自己解决这个问题。
当在Heroku上运行像Tweetstream (我相信它使用Eventmachine )这样的长时间运行的进程时,你必须使用worker dyno。如果一个进程没有在60秒内完成,web dyno就会超时。这就是我收到R10超时错误的原因。
要更改为worker dyno,我需要调整我的Procfile
web: bundle exec rackup config.ru -p $PORT至
worker: bundle exec rackup config.ru -p $PORT然后关闭web进程并打开名为“worker”的工作进程
> heroku ps:scale web=0 worker=1因为我只需要一个dyno在这个项目的这一点上工作。
https://stackoverflow.com/questions/13697618
复制相似问题