2015-10-18 60 views
1

我尝试通过gem Capistrano将我的应用程序部署到主机时出现问题。SSHKit :: Runner :: ExecuteError:执行时出现异常

我有一个出错列表:

(Backtrace restricted to imported tasks) 
    cap aborted! 
    SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: 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是:

[email protected]:~/apps/yurta24$ cap production deploy 
DEBUG [191cfb48] Running /usr/bin/env [ -d ~/.rvm ] as [email protected] 
DEBUG [191cfb48] Command: [ -d ~/.rvm ] 
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text. 
[email protected]'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 [email protected] 
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 [email protected] 
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 <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] 
DEBUG [363e1014] Finished in 0.374 seconds with exit status 0 (successful). 
rvm 1.26.11 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] 
DEBUG [0810a260] Running /usr/local/rvm/bin/rvm current as [email protected] 
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 [email protected] 
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 [email protected] 
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 [email protected]: 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 [email protected]: scp: /tmp/yurta24/git-ssh.sh: Permission denied 
[email protected]:~/apps/yurta24$ git checkout 
M config/deploy.rb 

谢谢

+0

我们可以看到完整的错误报告吗?这何时失败?在它失败之前它是否通过特定的卡皮斯特拉诺配方? – moeabdol

+0

也尝试$ cap生产部署:检查,并在那里报告相同的错误? – moeabdol

+0

@moeabdo,嗨。我已更新我的问题。是的,在它失败之前,它会通过特定的卡皮斯特拉诺配方。是的,我想,错误是一样的。 – verrom

回答

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的宝石,和Postgres宝石(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' 

Now!运行bundle install然后cap production deploy:check看看是否一切顺利。您可能需要为远程服务器postgres配置用户名和密码。

如果您面临更多麻烦,您可以按照this关于如何将Rails 4应用程序(Nginx + Capistrano + Unicorn)部署到Ubuntu VPS的完整指南。

希望这会有所帮助。

+0

这不起作用..我更新了我的问题。在database.yml中,我已将you_app_name_production更改为数据库名称,给我的托管服务器是什么,对吗? – verrom

+0

它应该是yurta24_production – moeabdol

+0

我已经将you_app_name_production更改为yurta24_production,并且错误是相同的。 – verrom

相关问题