Mina 无法加载 database.yml 文件中的环境变量,如下所述:
部署.rb:
task :deploy => :environment do
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
queue! "#{rake} db:seed"
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
end
end
vim ~/.bash_profile :
export MYSQLUSERNAME=mysql_user_name
export MYSQLPASSWORD=mysql_password
数据库.yml:
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: my_db_name
pool: 5
username: <%= ENV['MYSQLUSERNAME'] %>
password: <%= ENV['MYSQLPASSWORD'] %>
错误:
$ mina deploy
.....
.......
-----> DB migrations unchanged; skipping DB migration
$ RAILS_ENV="production" bundle exec rake db:seed
rake aborted!
Mysql2::Error: Access denied for user 'root'@'localhost' (using password: NO)
/home/user_name/.rvm/gems/ruby-2.0.0-p247/gems/mysql2-0.3.16/lib/mysql2/client.rb:70:in `connect'
注意:如果我在 database.yml 文件中替换用户名(mysql_user_name)和密码(mysql_user_name)值而不是 <%= ENV['MYSQLUSERNAME'] %> 和 <%= ENV['MYSQLPASSWORD'] %>,它工作得很好。
谁能帮助我在使用 Mina 部署时如何在 *.yml 文件中加载 ENV 变量。
谢谢!