簡體   English   中英

如何在Heroku上運行Tweetstream循環?

[英]How Do I Run a Tweetstream Loop on Heroku?

我有一個非常簡單的Tweetstream偵聽器,它內置在Sinatra應用程序中,試圖在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

它正在啟動流式偵聽器,並且如果我足夠快地進行鳴叫,它將對其進行接收,但是Heroku似乎在tweetstream循環中超時。 我怎樣才能解決這個問題?

所以我努力自己解決這個問題。

在Heroku上運行長時間運行的進程(如Tweetstream(我相信它使用Eventmachine))時,必須使用worker dyno。 如果過程在60秒內未完成,則Web dyno超時。 這就是為什么我收到R10超時錯誤。

要更改為工人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工作即可。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM