我一直在查看我的Heroku日志,我无法弄清楚为什么我的woker无法运行。它在本地工作,当我做heroku运行rake perform_later我得到一个响应,我的工作入队
Heroku记录
2016-02-09T20:02:04.364227+00:00 heroku[scheduler.2066]: State changed from up to complete
2016-02-09T20:02:04.350705+00:00 heroku[scheduler.2066]: Process exited with status 0
2016-02-09T21:00:57.182878+00:00 heroku[api]: Starting process with command `bundle exec rake perform_later` by scheduler@addons.heroku.com
2016-02-09T21:01:04.063903+00:00 heroku[scheduler.9121]: Starting process with command `bundle exec rake perform_later`
2016-02-09T21:01:04.681867+00:00 heroku[scheduler.9121]: State changed from starting to up
2016-02-09T21:01:07.923640+00:00 app[scheduler.9121]: [Simple Form] Simple Form is not configured in the application and will use the default values. Use `rails generate simple_form:install` to generate the Simple Form configuration.
2016-02-09T21:01:07.965160+00:00 app[scheduler.9121]: [ActiveJob] Enqueued GettweetsJob (Job ID: d3363b17-a2f9-4ffd-85b7-a5188b89605d) to Sidekiq(default)
2016-02-09T21:01:08.614883+00:00 heroku[scheduler.9121]: Process exited with status 0
2016-02-09T21:01:08.611923+00:00 heroku[scheduler.9121]: State changed from up to complete
2016-02-09T21:24:48.087768+00:00 heroku[web.1]: State changed from down to starting
2016-02-09T21:24:48.087325+00:00 heroku[web.1]: Unidling
2016-02-09T21:24:51.847314+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2016-02-09T21:24:53.513605+00:00 app[web.1]: [3] Puma starting in cluster mode...
2016-02-09T21:24:53.513625+00:00 app[web.1]: [3] * Version 2.15.3 (ruby 2.2.3-p173), codename: Autumn Arbor Airbrush
2016-02-09T21:24:53.513627+00:00 app[web.1]: [3] * Environment: production
2016-02-09T21:24:53.513663+00:00 app[web.1]: [3] * Preloading application
2016-02-09T21:24:53.513626+00:00 app[web.1]: [3] * Min threads: 3, max threads: 3
2016-02-09T21:24:53.513628+00:00 app[web.1]: [3] * Process workers: 2
2016-02-09T21:24:55.539022+00:00 app[web.1]: [3] * Listening on tcp://0.0.0.0:23385
2016-02-09T21:24:55.539160+00:00 app[web.1]: [3] Use Ctrl-C to stop
2016-02-09T21:24:55.544071+00:00 app[web.1]: [3] - Worker 0 (pid: 6) booted, phase: 0
2016-02-09T21:24:55.520328+00:00 app[web.1]: [Simple Form] Simple Form is not configured in the application and will use the default values. Use `rails generate simple_form:install` to generate the Simple Form configuration.
2016-02-09T21:24:55.545450+00:00 app[web.1]: [3] - Worker 1 (pid: 10) booted, phase: 0
2016-02-09T21:24:56.075839+00:00 heroku[web.1]: State changed from starting to up
作业
class GettweetsJob < ActiveJob::Base
queue_as :default
def perform(*args)
client = Twitter::REST::Client.new do |config|
config.consumer_key = "aaaa"
config.consumer_secret = "bbbb"
config.access_token = "cccc"
config.access_token_secret = "dddd"
end
client.mentions_timeline.each do |tweet|
Tweet.create({text: tweet.text, username: tweet.user.screen_name})
end
end
end
佣金任务
desc "This task is called by the Heroku scheduler add-on"
task :perform_later => :environment do
GettweetsJob.perform_later
end
响应heroku运行rake perform_later
[Simple Form] Simple Form is not configured in the application and will use the default values. Use `rails generate simple_form:install` to generate the Simple Form configuration.
[ActiveJob] Enqueued GettweetsJob (Job ID: 5f71c5e3-f2f3-4c5d-8396-1eb5cb25068b) to Sidekiq(default)
procfile
web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq -C config/sidekiq.yml
sidekiq.yml
:concurrency: 3
:timeout: 60
:verbose: true
:queues:
- default
- mailers