1

我正试图让我的应用程序在生产中工作。我有一个后台作业设置和一个静态调度程序(resque 和 resque_scheduler)。本地主机上的工人和排队工作没有任何问题。在 heroku 上,该作业显示在 resque_scheuler we UI 中,但从未被处理。它说“当前环境跳过突出显示的作业。”。如图所示,该作业标记为黄色。 具有突出显示的工作人员的调度程序 web ui

这是我的工作,日程安排和 procfile

tweet_sender.rb (工作)

class TweetSender
    @queue = :tweets_queue 

    def self.perform(tweet_id)
        @user = User.all
        @user.each do |u|
            current_user = u.id
            twt = Tweet.where(user_id: u.uid).where(status_id: 0).order(:created_at, :id).first
            if twt
                twt.status_id = 1
                twt.save
                client = u.twitter_client_from_user
                client.update(twt.text)
        end
    end
  end
end

tweet_schedule.yml

tweet_sender:
  every:
    - "30s"
    - :first_in: '10s'
  class: "TweetSender"
  queue: tweets_queue
  args: tweet_id
  rails_env: development
  description: "This job sends daily tweets from the content db"

档案

web: bundle exec rails server -p $PORT
resque: env TERM_CHILD=1 COUNT=1 QUEUE=* bundle exec rake resque:work 
worker: bundle exec rake environment=production resque:work COUNT=1 QUEUE=*
scheduler: bundle exec rake environment=production resque:scheduler

我浏览了文档,但找不到任何解释。有谁知道为什么要突出显示这项工作以及如何安排它。

4

1 回答 1

0

我认为这是因为您将tweet_schedule.yml工作设置为仅在rails_env: development. 要让您的工作在多个环境中运行(也可以说是生产环境),您必须将其设置为rails_env: development, production

tweet_sender:
  every:
    - "30s"
    - :first_in: '10s'
  class: "TweetSender"
  queue: tweets_queue
  args: tweet_id
  rails_env: development, production
  description: "This job sends daily tweets from the content db"
于 2018-05-22T00:19:55.813 回答