0

我正在使用 Capistrano 部署代码,这是以下内容deploy.rb

require 'bundler/capistrano'
set :application, "project_name"
set :use_sudo, false

set :scm, :git
set :repository, "git@bitbucket.org:my_name/fileito.git"
set :branch, "master"
set :deploy_via, :remote_cache
#set :deploy_via, :copy

set :user, "deployer"
set :password, "password"
set :deploy_to, "/home/deployer/project_name"
#set :app_site, "ec2-xx-xxx-xx-xxx.compute-1.amazonaws.com" 
set :app_site, "xx.xxx.xxx.xxx"

role :web, app_site                     # Your HTTP server, Apache/etc
role :app, app_site                     # This may be the same as your `Web` server
role :db,  app_site, :primary => true   # This is where Rails migrations will run

require 'capistrano-unicorn'
after 'deploy:restart', 'unicorn:reload' # app IS NOT preloaded
after 'deploy:restart', 'unicorn:restart'  # app preloaded

set :whenever_command, "bundle exec whenever"
require "whenever/capistrano/recipes"

# Added:
after "deploy:stop", "deploy:start"
namespace :deploy do
  task :start do
    run "/etc/init.d/apache2 start"
  end
  task :stop do
    run "/etc/init.d/apache2 stop"
  end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

但是当我部署新代码并在浏览器中检查应用程序时,我看到仍然存在旧代码。怎么了?当我查看current目录时,有新代码 - 我通过cat命令手动检查了文件。

浏览器中怎么可能仍然是旧版本->旧代码?

谢谢

4

1 回答 1

0

发生这种情况的原因有很多。以下是您应该检查的几个链接:

独角兽在部署+重启后继续使用旧代码

独角兽在旧版本目录中重新启动

使用 USR2 重启 Unicorn 似乎不会重新加载 production.rb 设置

于 2013-10-10T05:22:35.633 回答