简体   繁体   English

Heroku无法执行发条延迟的任务

[英]Heroku fails to perform clockwork delayed tasks

I am having a clockwork configuration file(inside the lib folder) that queues another file's methods to perform delayed tasks. 我有一个发条配置文件(在lib文件夹中),该文件将另一个文件的方法排队以执行延迟的任务。

require_relative "Adwords/Extractor"

It is working fine on my local machine (WEBrick running on win8). 在我的本地计算机(在Win8上运行的WEBrick)上运行正常。 However on heroku, it is failing with the following error: 但是在heroku上,它失败并显示以下错误:

 'app[web.1]: /app/lib/clock.rb:5:in `require_relative': cannot load such file -- /app/li
  b/Adwords/Extractor (LoadError)'

The Extractor.rb script is located at the same place as mentioned by the error statement. Extractor.rb脚本与错误语句提到的位置相同。

In Ruby 1.9.2 or higher no longer make the current directory . 在Ruby 1.9.2或更高版本中,不再创建当前目录。 part of your LOAD_PATH. LOAD_PATH的一部分。

You can get around it by using absolute paths 您可以使用绝对路径绕过它

File.expand_path(__FILE__) et al

or doing 或做

require './filename' (ironically).

or by using 或使用

require_relative 'filename'

require './filename' 

only works if your script is executed with the working directory set to the same directory that the script resides. 仅当您的脚本在工作目录设置为脚本所在的目录的情况下执行时才有效。 This is often not the case in multi-directory projects. 在多目录项目中通常不是这种情况。

try this out 试试这个

require "#{Rails.root}/app/lib/Adwords/Extractor"

use relative path to rails app. 使用Rails应用程序的相对路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM