2016-09-22 106 views
0

Capistrano的不部署

不過,服務器上的我的版本文件夾是空的。
這裏是我的deploy.rb:

# Default deploy_to directory is /var/www/my_app_name 
    set :deploy_to, "/home/#{fetch(:user)}/apps1/#{fetch(:application)}" 

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

    # Default value for :format is :pretty 
    # set :format, :pretty 

    # Default value for :log_level is :debug 
    # set :log_level, :debug 

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

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

    # Default value for linked_dirs is [] 
    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, { path2: "/opt/ruby/bin:$PATH" } 

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

    namespace :deploy do 
     %w[start stop restart].each do |command| 
     desc "#{command} unicorn server" 
     task command do 
      on roles :app do 
      execute "/etc/init.d/unicorn_#{fetch(:application)} #{command}" 
      end 
     end 
     end 
     task :setup_config do 
     on roles :app do 
      sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{fetch(:application)}" 
      sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{fetch(:application)}" 
      execute "mkdir -p #{shared_path}/config" 
      execute "mkdir -p #{shared_path}/socket" 
     end 
     end 
     # after 'deploy:setup', 'deploy:setup_config' 

     # task :symlink_config do 
     # on roles :app do 
     #  execute "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" 
     # end 
     # end 
     # after 'deploy:updated', 'deploy:symlink_config' 

     desc 'Make sure local git is in sync with remote.' 
     task :check_revision do 
     on roles :web do 
      unless `git rev-parse HEAD` == `git rev-parse origin/master` 
      puts 'WARNING: HEAD is not the same as origin/master' 
      puts 'Run `git push` to sync changes.' 
      exit 
      end 
     end 
     end 
     before 'deploy', 'deploy:check_revision' 

    end 

這裏是我的控制檯日誌(my_ip是服務器的ip,my_user是我的服務器用戶名,my_local_user是我的本地用戶名):

rvm 1.27.0 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] 
    ruby-2.3.0 
    ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] 
    00:00 git:wrapper 
      01 mkdir -p /tmp 
     ✔ 01 [email protected]_ip 0.027s 
      Uploading /tmp/git-ssh-my_app-production-my_local_user.sh 100.0% 
      02 chmod 700 /tmp/git-ssh-my_app-production-my_local_user.sh 
     ✔ 02 [email protected]_ip 0.036s 
    00:00 git:check 
      01 git ls-remote --heads [email protected]:my_app/my_app.git 
      01 b440ec9ce098e4cfb733a39f2f65c898ce579583 refs/heads/master 
     ✔ 01 [email protected]_ip 2.748s 
    00:02 deploy:check:directories 
      01 mkdir -p /home/my_user/apps1/my_app/shared /home/my_user/apps1/my_app/releases 
     ✔ 01 [email protected]_ip 0.015s 
    00:02 deploy:check:linked_dirs 
      01 mkdir -p /home/my_user/apps1/my_app/shared/log /home/my_user/apps1/my_app/shared/tmp/pids /home/my_user/apps1/my_app/shared/tmp/cache /home/my_user/apps1/my_app/shared/tmp/so… 
     ✔ 01 [email protected]_ip 0.014s 
    00:02 deploy:check:make_linked_dirs 
      01 mkdir -p /home/my_user/apps1/my_app/shared/config 
     ✔ 01 [email protected]_ip 0.012s 
    00:03 deploy:check:linked_files 
      linked file /home/my_user/apps1/my_app/shared/config/database.yml does not exist on my_ip 

如果我刪除部署目錄或當前版本,或更改部署目錄,日誌相同。

任何幫助表示讚賞。

+0

'鏈接文件/home/my_user/apps1/my_app/shared/config/database.yml在my_ip'上不存在這似乎是原因(如果這確實是日誌的最後一行)。確保database.yml文件位於cap所期望的位置。 –

+1

@PrakashMurthy,我解決了這個問題,然後是與secrets.yml類似的消息。我scp'ed這個文件,並工作!謝謝!日誌中沒有任何錯誤,所以我決定,Capistrano只是沒有做一些任務。 –

回答

0

移動從上面的評論的答案:

linked file /home/my_user/apps1/my_app/shared/config/database.yml does not exist on my_ip這似乎是這個原因(如果確實是日誌中的最後一行)。確保database.yml文件存在於位置上限所期望的位置。