从rake任务验证Heroku gem

时间:2015-05-31 17:47:00

标签: ruby-on-rails heroku rake

我想让自动备份脚本正常工作。我正在使用heroku gem。该脚本正在从Heroku的Scheduler插件中运行。

require "heroku/command/pg"
require "heroku/command/pg_backups"

....
def initialize
  @client     = Heroku::Command::Pg.new([], app: ENV['APP_NAME'])
end

...
attachment = @client.send(:generate_resolver)
...

一旦我调用attachment = @client.send(:generate_resolver),脚本就会停止执行并要求

Enter your Heroku credentials.
Email: 

有没有办法避免这种情况,因为无论如何都要从heroku中启动任务,因此应该已经过身份验证。

非常感谢任何帮助

1 个答案:

答案 0 :(得分:1)

对于非交互式登录,您需要使用API​​密钥,HEROKU_API_KEY环境变量中的Heroku will read。您可以使用heroku auth:token从登录的CLI中为您的帐户fetch the key

由于你已经在Heroku中运行,因此无法避免身份验证。这将对应用程序之间的安全性产生重大影响。

同时查看pgbackups-archive。看起来它完成了你所追求的目标,或者至少可能为你提供一些有用的技巧。