简体   繁体   中英

Capistrano doesn't deploy

When I run

bundle exec cap production deploy 

Capistrano starts doing tasks, but stops after checking tasks and exit.

Nevertheless, my releases folder on server is empty.
Here is my 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

Here is my console log(my_ip is server ip, my_user is my server username, my_local_user is my local username):

    rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [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 my_user@my_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 my_user@my_ip 0.036s
    00:00 git:check
          01 git ls-remote --heads git@bitbucket.org:my_app/my_app.git
          01 b440ec9ce098e4cfb733a39f2f65c898ce579583   refs/heads/master
        ✔ 01 my_user@my_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 my_user@my_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 my_user@my_ip 0.014s
    00:02 deploy:check:make_linked_dirs
          01 mkdir -p /home/my_user/apps1/my_app/shared/config
        ✔ 01 my_user@my_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

If I delete deploy directory or current release, or change deploy directory, logs are same.

Any help is appreciated.

Moving the answer from the comment above:

linked file /home/my_user/apps1/my_app/shared/config/database.yml does not exist on my_ip This seems to be the reason (if that is indeed the last line in the log). Make sure the database.yml file is present at the location cap is expecting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM