【问题标题】:Rails3 capistrano, postgresql roles and deploying assetsRails3 capistrano、postgresql 角色和部署资产
【发布时间】:2014-06-23 06:36:41
【问题描述】:

上下文是一个试运行,首先测试开发中的资产部署,然后再投入生产。
取消注释以下 capfile 中的行

load 'deploy'
    # load 'deploy/assets'
load 'config/deploy' 

生成回滚,因为 capistrano 进程正在创建清单文件

bundle exec rake RAILS_ENV=development RAILS_GROUPS=assets assets:precompile && cp -- /Users/stageUser/v4/shared/assets/manifest.yml /Users/stageUser/v4/releases/20140623054425/assets_manifest.yml"

遇到错误

 ** [out :: ip] rake aborted!
 ** [out :: ip] FATAL:  role "localhostUser" does not exist
 ** [out :: ip] /Users/stageUser/v4/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize'
 ** [out :: ip] /Users/stageUser/v4/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `new'
 ** [out :: ip] /Users/stageUser/v4/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `connect'
 ** [out :: ip] /Users/stageUser/v4/shared/bundle/ruby/1.9.1/

localhostUser 不会在登台服务器上的任何位置、deploy.rb 或 Capfile 中调用。它仅定义用于本地主机上的开发和测试数据库使用。该错误显然是通过 postgresql_adapter.rb 发生的

更新怪事。关闭错误参考状态:

failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3@v4'

ruby 版本 1.9.3 ... 与 ruby​​ 的捆绑路径在 1.9.1 ... 嗯。这可能有关系吗? 结束更新

部署/资产调用的 postgresql_adapter 是什么。唯一的线索是可以作为数据库初始化程序读取的 manifests.yml 文件...该行确实调用了 'connection_parameters' 但是为什么当 stageServer 不知道它时它使用 localhostUser 呢?

database.yml 用户名在 localhost 和登台服务器之间的定义不同,但我无法理解为什么这会影响 capfile。

如何确保角色设置正确?

【问题讨论】:

    标签: postgresql ruby-on-rails-3.2 capistrano asset-pipeline


    【解决方案1】:

    下面是一个补丁,但不是问题的正确答案。

    这一切都与 postgresql 及其角色有关。我的 database.yml 文件是 .gitignore(d) 我有不同的用户名值(或 postgresql 的“角色”)

    sudo su localhostUser
    

    这不是 postgre(有点复杂,把我扔到另一个集群)

    createuser stageUser
    

    我承认我不确定这是否是解决方案的必要部分,但是 WT... 安全行事

    然后,按顺序:

    pg_dump app_development > mydb.sql
    rake db:migrate VERSION=0
    

    将 database.yml 文件中的用户名从 localhostUser 更改为 stageUser

    rake db:migrate
    

    编辑 mydb.sql 将 localhostUser 字符串替换为 stageUser

    psql app_development < mydb.sql
    

    部署现在运行。

    这确认该任务没有使用登台服务器的 database.yml 数据,而是使用来自 localhost 的一些缓存。 不是我所期望的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-04
      • 1970-01-01
      • 2023-04-06
      • 2014-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多