![](/img/trans.png)
[英]Can't make calls to heroku CLI from within a Rake task without the Heroku gem in the Gemfile
[英]Authenticating Heroku gem from rake task
我正在尝试使我的自动备份脚本正常工作。 我正在使用heroku宝石。 该脚本是通过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内部发起的,因此应该已经通过了身份验证。
任何帮助深表感谢
对于非交互式登录,您需要使用API密钥,Heroku 会从HEROKU_API_KEY
环境变量中读取该API密钥。 您可以使用heroku auth:token
从登录的CLI中获取帐户的密钥 。
仅仅因为您已经在Heroku内部运行,就无法避免身份验证。 这将对应用程序间的安全性产生重大影响。
还要检查pgbackups-archive 。 看起来它确实可以满足您的需求,或者至少可以为您提供一些有用的技术。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.