2016-09-22 105 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文件存在于位置上限所期望的位置。