2015-10-18 89 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

相關問題