【问题标题】:Running Rake Task with Clock Process使用时钟进程运行 Rake 任务
【发布时间】:2013-07-14 02:36:17
【问题描述】:

在我的 Heroku 应用程序中,我有一个需要定期执行 rake 任务的时钟进程。我正在使用时钟 gem。这是 lib/clock.rb 中的代码:

require File.expand_path('../../config/boot',        __FILE__)
require File.expand_path('../../config/environment', __FILE__)
require 'clockwork'

include Clockwork

every(1.day, 'API Data Fetching', :at => '18:31') { `rake build_index` }

这里是 Heroku 日志 sn-p:

2013-07-15T18:31:00.716092+00:00 app[clock.1]: I, [2013-07-15T18:31:00.673880 #2]  INFO -- : Triggering 'API Data Fetching'
2013-07-15T18:31:39.131681+00:00 app[clock.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
2013-07-15T18:31:39.132841+00:00 app[clock.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
2013-07-15T18:31:39.132346+00:00 app[clock.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)

没有执行任务,也没有获取 API 数据。可能是什么问题?从 clock.rb 运行 rake 任务是个坏主意吗?

【问题讨论】:

    标签: ruby-on-rails heroku scheduled-tasks clockwork


    【解决方案1】:

    长时间后回答 :) 但您需要添加 Procfile 以使用 heroku this question 工作时钟工作宝石可能会帮助您。

    【讨论】:

      猜你喜欢
      • 2014-12-05
      • 1970-01-01
      • 2012-05-30
      • 2015-04-15
      • 2010-10-09
      • 1970-01-01
      • 2012-11-15
      • 2017-07-19
      相关资源
      最近更新 更多