2016-09-18 69 views
0

不知道Capistrano試圖做什麼或出了什麼問題。我已經設置了文件和文件夾的權限在我的服務器上對用戶「deploy4」,並在這裏的一切必要的事情提到:Capistrano部署錯誤 - 「config/database.yml:沒有這樣的文件或目錄」

https://www.phusionpassenger.com/library/deploy/apache/automating_app_updates/ruby/#setting-up-a-basic-directory-structure

我已經嘗試了所有其他解決方法,但沒有任何工程,我也有嘗試將我的web dir移動到deploy4 home而不是服務器「/ var/www /」,同樣也發生了同樣的錯誤。我也有.gitignore數據庫和secrets.yml文件。

同樣的問題適用於secrets.yml文件

的Rails:5.0.0.1,紅寶石:2.3.1,Capistrano的:3.6.1

Capistrano的日誌:

**********@**********:~/Documents/**********/group4$ cap production deploy --trace 
** Invoke production (first_time) 
** Execute production 
** Invoke load:defaults (first_time) 
** Execute load:defaults 
** Invoke rbenv:validate (first_time) 
** Invoke rbenv:install (first_time) 
** Execute rbenv:install 
** Invoke rbenv:install_rbenv (first_time) 
** Execute rbenv:install_rbenv 
** Invoke rbenv:install_ruby_build (first_time) 
** Execute rbenv:install_ruby_build 
** Invoke rbenv:install_ruby (first_time) 
** Execute rbenv:install_ruby 
** Invoke rbenv:install_bundler (first_time) 
** Invoke rbenv:map_bins (first_time) 
** Invoke passenger:rbenv:hook (first_time) 
** Invoke passenger:test_which_passenger (first_time) 
** Execute passenger:test_which_passenger 
** Execute passenger:rbenv:hook 
** Execute rbenv:map_bins 
** Execute rbenv:install_bundler 
** Execute rbenv:validate 
** Invoke rbenv:map_bins 
** Invoke bundler:map_bins (first_time) 
** Invoke passenger:bundler:hook (first_time) 
** Execute passenger:bundler:hook 
** Execute bundler:map_bins 
** Invoke deploy:set_rails_env (first_time) 
** Execute deploy:set_rails_env 
** Invoke deploy:set_linked_dirs (first_time) 
** Execute deploy:set_linked_dirs 
** Invoke deploy:set_rails_env 
** Invoke deploy (first_time) 
** Execute deploy 
** Invoke deploy:starting (first_time) 
** Execute deploy:starting 
** Invoke deploy:check (first_time) 
** Execute deploy:check 
** Invoke git:check (first_time) 
** Invoke git:wrapper (first_time) 
** Execute git:wrapper 
00:00 git:wrapper 
     01 mkdir -p /tmp 
    ✔ 01 [email protected]********** 0.011s 
    ✔ 01 [email protected]********** 0.013s 
     Uploading /tmp/git-ssh-group4-production-**********.sh 100.0% 
     Uploading /tmp/git-ssh-group4-production-**********.sh 100.0% 
     02 chmod 700 /tmp/git-ssh-group4-production-**********.sh 
    ✔ 02 [email protected]********** 0.011s 
    ✔ 02 [email protected]********** 0.012s 
** Execute git:check 
00:00 git:check 
     01 git ls-remote --heads [email protected]**********.git 
     01 7651cd0265b7494eb5b16e47d056e3f9a52795cc refs/heads/master 
     01 7651cd0265b7494eb5b16e47d056e3f9a52795cc refs/heads/master 
    ✔ 01 [email protected]********** 4.835s 
    ✔ 01 [email protected]********** 4.836s 
** Invoke deploy:check:directories (first_time) 
** Execute deploy:check:directories 
00:04 deploy:check:directories 
     01 mkdir -p /var/www/web/group4/shared /var/www/web/group4/releases 
    ✔ 01 [email protected]********** 0.012s 
    ✔ 01 [email protected]********** 0.013s 
** Invoke deploy:check:linked_dirs (first_time) 
** Execute deploy:check:linked_dirs 
00:04 deploy:check:linked_dirs 
     01 mkdir -p /var/www/web/group4/shared/log /var/www/web/group4/shared/tmp/pids /var/www/web/group4/shared/tmp… 
    ✔ 01 [email protected]********** 0.022s 
    ✔ 01 [email protected]********** 0.021s 
** Invoke deploy:check:make_linked_dirs (first_time) 
** Execute deploy:check:make_linked_dirs 
00:04 deploy:check:make_linked_dirs 
     01 mkdir -p /var/www/web/group4/shared/config 
    ✔ 01 [email protected]********** 0.011s 
    ✔ 01 [email protected]********** 0.011s 
** Invoke deploy:check:linked_files (first_time) 
** Execute deploy:check:linked_files 
** Invoke deploy:set_previous_revision (first_time) 
** Execute deploy:set_previous_revision 
** Invoke deploy:started (first_time) 
** Execute deploy:started 
** Invoke secrets_yml:secrets_yml_symlink (first_time) 
** Execute secrets_yml:secrets_yml_symlink 
** Invoke deploy:updating (first_time) 
** Invoke deploy:new_release_path (first_time) 
** Execute deploy:new_release_path 
** Execute deploy:updating 
** Invoke git:create_release (first_time) 
** Invoke git:update (first_time) 
** Invoke git:clone (first_time) 
** Invoke git:wrapper 
** Execute git:clone 
00:05 git:clone 
     The repository mirror is at /var/www/web/group4/repo 
     The repository mirror is at /var/www/web/group4/repo 
** Execute git:update 
00:05 git:update 
     01 git remote update --prune 
     01 Fetching origin 
     01 Fetching origin 
    ✔ 01 [email protected]********** 4.824s 
    ✔ 01 [email protected]********** 4.821s 
** Execute git:create_release 
00:09 git:create_release 
     01 mkdir -p /var/www/web/group4/releases/20160918214854 
    ✔ 01 [email protected]********** 0.012s 
     02 git archive master group4 | tar -x --strip-components 1 -f - -C /var/www/web/group4/releases/20160918214854 
    ✔ 01 [email protected]********** 0.012s 
    ✔ 02 [email protected]********** 0.033s 
    ✔ 02 [email protected]********** 0.034s 
** Invoke deploy:set_current_revision (first_time) 
** Execute deploy:set_current_revision 
** Invoke git:set_current_revision (first_time) 
** Execute git:set_current_revision 
00:09 git:set_current_revision 
     01 echo "7651cd0265b7494eb5b16e47d056e3f9a52795cc" >> REVISION 
    ✔ 01 [email protected]********** 0.011s 
    ✔ 01 [email protected]********** 0.012s 
** Invoke deploy:symlink:shared (first_time) 
** Execute deploy:symlink:shared 
** Invoke deploy:symlink:linked_files (first_time) 
** Execute deploy:symlink:linked_files 
00:09 deploy:symlink:linked_files 
     01 mkdir -p /var/www/web/group4/releases/20160918214854/config 
    ✔ 01 [email protected]********** 0.011s 
    ✔ 01 [email protected]********** 0.014s 
     02 rm /var/www/web/group4/releases/20160918214854/config/database.yml 
    ✔ 02 [email protected]********** 0.011s 
     03 ln -s /var/www/web/group4/shared/config/database.yml /var/www/web/group4/releases/20160918214854/config/da… 
     02 rm: cannot remove '/var/www/web/group4/releases/20160918214854/config/database.yml': No such file or direc… 
cap aborted! 
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]**********: rm exit status: 1 
rm stdout: Nothing written 
rm stderr: rm: cannot remove '/var/www/web/group4/releases/20160918214854/config/database.yml': No such file or directory 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute' 
SSHKit::Command::Failed: rm exit status: 1 
rm stdout: Nothing written 
rm stderr: rm: cannot remove '/var/www/web/group4/releases/20160918214854/config/database.yml': No such file or directory 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/command.rb:100:in `exit_status=' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/netssh.rb:148:in `execute_command' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:141:in `block in create_command_and_execute' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:141:in `tap' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:74:in `execute' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.6.1/lib/capistrano/tasks/deploy.rake:143:in `block (5 levels) in <top (required)>' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.6.1/lib/capistrano/tasks/deploy.rake:139:in `each' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.6.1/lib/capistrano/tasks/deploy.rake:139:in `block (4 levels) in <top (required)>' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:29:in `instance_exec' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:29:in `run' 
/home/**********/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute' 
Tasks: TOP => deploy:symlink:linked_files 
The deploy has failed with an error: Exception while executing as [email protected]**********: rm exit status: 1 
rm stdout: Nothing written 
rm stderr: rm: cannot remove '/var/www/web/group4/releases/20160918214854/config/database.yml': No such file or directory 
** Invoke deploy:failed (first_time) 
** Execute deploy:failed 

** DEPLOY FAILED 
** Refer to log/capistrano.log for details. Here are the last 20 lines: 

DEBUG [6bf2cf17] Command: [ -L /var/www/web/group4/releases/20160918214854/config/database.yml ] 
INFO [ce01eb8c] Finished in 0.014 seconds with exit status 0 (successful). 
DEBUG [1aa31b6f] Running [ -L /var/www/web/group4/releases/20160918214854/config/database.yml ] as [email protected]********** 
DEBUG [1aa31b6f] Command: [ -L /var/www/web/group4/releases/20160918214854/config/database.yml ] 
DEBUG [6bf2cf17] Finished in 0.007 seconds with exit status 1 (failed). 
DEBUG [d065dc4b] Running [ -f /var/www/web/group4/releases/20160918214854/config/database.yml ] as [email protected]********** 
DEBUG [d065dc4b] Command: [ -f /var/www/web/group4/releases/20160918214854/config/database.yml ] 
DEBUG [1aa31b6f] Finished in 0.007 seconds with exit status 1 (failed). 
DEBUG [a8a079de] Running [ -f /var/www/web/group4/releases/20160918214854/config/database.yml ] as [email protected]********** 
DEBUG [a8a079de] Command: [ -f /var/www/web/group4/releases/20160918214854/config/database.yml ] 
DEBUG [d065dc4b] Finished in 0.007 seconds with exit status 0 (successful). 
INFO [c01dbafb] Running /usr/bin/env rm /var/www/web/group4/releases/20160918214854/config/database.yml as [email protected]********** 
DEBUG [c01dbafb] Command: (export BAZOOKA_USER="**********" http_proxy="**********" https_proxy="**********" ftp_proxy="**********" rsync_proxy="**********" no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com" HTTP_PROXY="" HTTPS_PROXY="" FTP_PROXY="" RSYNC_PROXY="" NO_PROXY="" RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.3.1" ; /usr/bin/env rm /var/www/web/group4/releases/20160918214854/config/database.yml) 
DEBUG [a8a079de] Finished in 0.007 seconds with exit status 0 (successful). 
INFO [4c6e0f98] Running /usr/bin/env rm /var/www/web/group4/releases/20160918214854/config/database.yml as [email protected]********** 
DEBUG [4c6e0f98] Command: (export BAZOOKA_USER="**********" http_proxy="**********" https_proxy="**********" ftp_proxy="**********" rsync_proxy="**********" no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com" HTTP_PROXY="" HTTPS_PROXY="" FTP_PROXY="" RSYNC_PROXY="" NO_PROXY="" RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.3.1" ; /usr/bin/env rm /var/www/web/group4/releases/20160918214854/config/database.yml) 
INFO [c01dbafb] Finished in 0.011 seconds with exit status 0 (successful). 
INFO [67264213] Running /usr/bin/env ln -s /var/www/web/group4/shared/config/database.yml /var/www/web/group4/releases/20160918214854/config/database.yml as [email protected]********** 
DEBUG [67264213] Command: (export BAZOOKA_USER="**********" http_proxy="**********" https_proxy="**********" ftp_proxy="**********" rsync_proxy="**********" no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com" HTTP_PROXY="" HTTPS_PROXY="" FTP_PROXY="" RSYNC_PROXY="" NO_PROXY="" RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.3.1" ; /usr/bin/env ln -s /var/www/web/group4/shared/config/database.yml /var/www/web/group4/releases/20160918214854/config/database.yml) 
DEBUG [4c6e0f98] rm: cannot remove '/var/www/web/group4/releases/20160918214854/config/database.yml': No such file or directory 

配置/ deploy.rb文件:

# Config valid only for current version of Capistrano 
lock '3.6.1' 

#Set app details 
set :application, 'group4' 
set :repo_url, '[email protected]**********' 

#For restarting Apache 
set :passenger_restart_with_touch, true 

# Default branch is :master 
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp 
set :stages,['production'] 
set :default_stage, 'production' 
set :user, 'deploy4' 
set :branch, 'master' 

# Default deploy_to directory is /var/www/my_app_name 
set :deploy_to, '/var/www/web/group4' 

# Default value for :scm is :git 
set :scm, :git 

#Set Ruby versions 
set :rbenv_type, :user 
set :rbenv_ruby, '2.3.1' 
set :repo_tree, 'group4' 

# Default value for :format is :airbrussh. 
# set :format, :airbrussh 

# You can configure the Airbrussh format using :format_options. 
# These are the defaults. 
# set :format_options, command_output: true, log_file: 'log/capistrano.log', color: :auto, truncate: :auto 

# Default value for :pty is false 
# set :pty, true 

# Default value for :linked_files is [] 
#append :linked_files, 'config/database.yml', 'config/secrets.yml' 
set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml') 

# Default value for linked_dirs is [] 
#append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system' 
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system') 

# Default value for default_env is {} 
# set :default_env, { path: "/opt/ruby/bin:$PATH" } 

# Default value for keep_releases is 5 
set :keep_releases, 5 

配置/部署/ production.rb文件:

# Role-based syntax 
role :app, %w{[email protected]**********} 
role :web, %w{[email protected]**********} 
role :db, %w{[email protected]**********}, :primary => true 

# Configurations 
set :branch, 'master' 
set :rails_env, "production" 
set :deploy_to, "/var/www/web/group4" 

set :default_env,{ 
    'BAZOOKA_USER' => ENV['BAZOOKA_USER'], 

    "http_proxy" => "**********", 
    "https_proxy" => "**********", 
    "ftp_proxy" => "**********", 
    "rsync_proxy" => "**********", 
    "no_proxy" => "localhost,127.0.0.1,localaddress,.localdomain.com", 

    "HTTP_PROXY" => $http_proxy, 
    "HTTPS_PROXY" => $https_proxy, 
    "FTP_PROXY" => $ftp_proxy, 
    "RSYNC_PROXY" => $rsync_proxy, 
    "NO_PROXY" => $no_proxy 
} 

# Custom SSH Options 
server '**********', 
    user: 'deploy4', 
    roles: %w{web app db}, 
    ssh_options: { 
    user: 'deploy4', 
    keys: %w(/home/**********/.ssh/id_rsa), 
    forward_agent: true, 
    auth_methods: %w(publickey password), 
    password: '**********' 
} 

at /var/www/web/group4/shared/config folder

回答

0

我通常在兩種情況之一看到了這一點:

  1. 是否/var/www/web/group4/shared/config/database.yml您的服務器上存在?
  2. /var/www/web/group4/shared/config/database.yml符號鏈接到不存在的文件(或相對符號鏈接)?
+0

是的問題1,但不知道關於問題2。 –

相關問題