jeudi 27 juillet 2017

Capistrano 3: After deployment is not "refreshed" code (website stays as prior the deploy)

I was doing some modification on the website (pure HTML+CSS), deployed it on the server and after refreshing the browser the content was the same.

So I logged in on the server, killed unicorn, started it manually and the new content finally appeared.

How do I do this automatically?

Currently, I have this deploy.rb setup:

# config valid only for current version of Capistrano
lock "3.8.1"

set :application, "project"
set :repo_url, "git@bitbucket.org:username/project.git"
set :branch, "master"
set :tmp_dir, '/home/deployer/tmp'

set :deploy_to, "/home/deployer/apps/project"
set :keep_releases, 5

set(:executable_config_files, %w(
  unicorn_init.sh
))

# files which need to be symlinked to other parts of the
# filesystem. For example nginx virtualhosts, log rotation
# init scripts etc.
set(:symlinks, [
  {
    source: "nginx.conf",
    link: "/etc/nginx/sites-enabled/default"
  },
  {
    source: "unicorn_init.sh",
    link: "/etc/init.d/unicorn_#{fetch(:application)}"
  },
  {
    source: "log_rotation",
   link: "/etc/logrotate.d/#{fetch(:application)}"
  },
  {
    source: "monit",
    link: "/etc/monit/conf.d/#{fetch(:application)}.conf"
  }
])


namespace :deploy do   
  desc 'Restart application'
  task :restart do
    task :restart do
      invoke 'unicorn:reload'
    end
  end
  after :publishing, :restart    

  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

What do I need to add yet in order to don't need to manually restart server?

Thank you

Aucun commentaire:

Enregistrer un commentaire