尝试通过gem Capistrano将我的应用部署到主机时遇到问题。
我有下一个错误列表:
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as hosting_yurta24@calcium.locum.ru: rake exit status: 1
我的deploy.rb文件是:
lock '3.4.0'
application = 'yurta24'
login = 'yurta24'
$user = 'hosting_' + login
$server = 'calcium.locum.ru'
rvm_ruby_string = '2.1.5p273'
deploy_to = "/home/#{ $user }/projects/#{ application }"
unicorn_conf = "/etc/unicorn/#{ application }.#{ login }.rb"
unicorn_pid = "/var/run/unicorn/#{ $user }/#{ application }.#{ login }.pid"
unicorn_start_cmd = "(cd #{ deploy_to }/current; rvm use #{ rvm_ruby_string } do bundle exec unicorn_rails -Dc #{ unicorn_conf })"
set :application, application
set :repo_url, "https://github.com/verrom/yurta24.git"
set :deploy_to, deploy_to
set :pty, true
set :default_env, { path: "xxxxx" }
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
我的production.rb文件是:
connect_to = "#{$user}@#{$server}"
role :app, [connect_to]
role :web, [connect_to]
role :db, [connect_to]
set :enable_ssl, true
更新database.yml后的完整更新错误报告是:
verevkinra@ubuntu:~/apps/yurta24$ cap production deploy
DEBUG [191cfb48] Running /usr/bin/env [ -d ~/.rvm ] as hosting_yurta24@calcium.locum.ru
DEBUG [191cfb48] Command: [ -d ~/.rvm ]
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
hosting_yurta24@calcium.locum.ru's password:xxxxxxxxxxx
DEBUG [191cfb48] Finished in 5.999 seconds with exit status 1 (failed).
DEBUG [cba4e265] Running /usr/bin/env [ -d /usr/local/rvm ] as hosting_yurta24@calcium.locum.ru
DEBUG [cba4e265] Command: [ -d /usr/local/rvm ]
DEBUG [cba4e265] Finished in 0.171 seconds with exit status 0 (successful).
DEBUG [363e1014] Running /usr/local/rvm/bin/rvm version as hosting_yurta24@calcium.locum.ru
DEBUG [363e1014] Command: ( PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/local/rvm/bin/rvm version )
DEBUG [363e1014] rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [363e1014] Finished in 0.374 seconds with exit status 0 (successful).
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [0810a260] Running /usr/local/rvm/bin/rvm current as hosting_yurta24@calcium.locum.ru
DEBUG [0810a260] Command: ( PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/local/rvm/bin/rvm current )
DEBUG [0810a260] system
DEBUG [0810a260] Finished in 0.391 seconds with exit status 0 (successful).
system
DEBUG [769f1945] Running /usr/local/rvm/bin/rvm default do ruby --version as hosting_yurta24@calcium.locum.ru
DEBUG [769f1945] Command: ( PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/local/rvm/bin/rvm default do ruby --version )
DEBUG [769f1945] ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
DEBUG [769f1945]
DEBUG [769f1945] Finished in 0.605 seconds with exit status 0 (successful).
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
INFO [b1cf993c] Running /usr/bin/env mkdir -p /tmp/yurta24/ as hosting_yurta24@calcium.locum.ru
DEBUG [b1cf993c] Command: ( PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/bin/env mkdir -p /tmp/yurta24/ )
INFO [b1cf993c] Finished in 0.170 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/yurta24/git-ssh.sh 0.0%
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as hosting_yurta24@calcium.locum.ru: scp: /tmp/yurta24/git-ssh.sh: Permission denied
scp: /tmp/yurta24/git-ssh.sh: Permission denied
Tasks: TOP => git:check => git:wrapper
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as hosting_yurta24@calcium.locum.ru: scp: /tmp/yurta24/git-ssh.sh: Permission denied
verevkinra@ubuntu:~/apps/yurta24$ git checkout
M config/deploy.rb
由于
答案 0 :(得分:1)
因此,capistrano报告您在database.yml生产中缺少数据库适配器。您似乎错误地将postgresql放置为数据库名称而不是适配器名称。
在您的database.yml中,您应该拥有以下内容:
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: postgresql
database: you_app_name_production
username: yourdatabaseusername #in most cases this will be postgres
password: youdatabasepassword
pool: 5
timeout: 5000
在你的Gemfile中确保你在开发和测试gourp中有sqlite gem,在produciton中有postgres gem(pg),如下所示:
group :development, :test do
# all your other dev and test gems
gem 'sqlite3'
end
# outsite your developement and test group add this
gem 'pg'
现在!运行bundle install
然后cap production deploy:check
查看一切进展顺利。您可能需要为用户名和密码配置远程服务器postgres。
如果您面临更多麻烦,可以按照this完整指南,了解如何将Rails 4应用程序(Nginx + Capistrano + Unicorn)部署到您的Ubuntu VPS。
希望这有帮助。