我们有一个用于带有Apache,Phusion Passenger和Capistrano 3的Rails 4应用程序的生产环境,以及一个远程bitbucket存储库.Capistrano的"上限生产部署"效果很好,并且可以正常执行.但是当我们转到远程服务器上的"current"文件夹并执行"git log"命令时,我们的远程存储库的最后一次提交都没有加载.
我们在我们的应用程序的主文件夹中尝试了"git log",同样的问题.
我们的问题是,我们可以将我们的repo的最后提交加载到生产环境中?卡皮斯特拉诺不是默认做的吗?
知道它可能来自哪里?
以下是我们的Capfile,deploy.rb和deploy/production.rb文件的代码:
Capfile
# Load DSL and Setup Up Stages require 'capistrano/setup' # Includes default deployment tasks require 'capistrano/deploy' require 'rvm1/capistrano3' require 'capistrano/bundler' require 'capistrano/rails/assets' require 'capistrano/rails/migrations' # Loads custom tasks from `lib/capistrano/tasks' if you have any defined. Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } Dir.glob('lib/capistrano/**/*.rb').each { |r| import r }
deploy.rb
lock '3.1.0' set :application, 'XXXXXXX' set :deploy_user, 'XXXXXXX' set :repo_url, 'GIT_REPO_URL.XXXXXXX.git' set :keep_releases, 5 set :rvm_type, :user set :rvm_ruby_version, 'ruby-2.1.2' set :default_env, { rvm_bin_path: '/usr/local/rvm/bin' } set :bundle_dir, "/usr/local/bin" set :ssh_options, {:forward_agent => true} set :linked_files, %w{config/database.yml config/application.yml} set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} set :tests, [] set(:config_files, %w( apache2.conf database.example.yml log_rotation unicorn.rb unicorn_init.sh )) set :log_level, :debug set :pty, true set :assets_roles, [:app] # which config files should be made executable after copying # by deploy:setup_config 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: "apache2.conf", link: "/etc/apache2/sites-enabled/#{fetch(:full_app_name)}" }, { source: "unicorn_init.sh", link: "/etc/init.d/unicorn_#{fetch(:full_app_name)}" }, { source: "log_rotation", link: "/etc/logrotate.d/#{fetch(:full_app_name)}" } ]) namespace :deploy do task :start do ; end task :stop do ; end desc 'Restart application' task :restart do on roles(:all), in: :sequence, wait: 5 do # Your restart mechanism here, for example: execute :touch, release_path.join('restart.txt') end end task :stop_node do on roles(:all), in: :sequence do #Stop the node_server execute "nohup node ./realtime/node_server.js &" end end task :restart_node do on roles(:all), in: :sequence do #Restart the node_server execute "nohup node ./realtime/node_server.js &" end end end # Bundle install configuration set :bundle_without, %w{development test}.join(' ') set :bundle_roles, :all namespace :bundler do desc "Install gems with bundler." task :install do on roles fetch(:bundle_roles) do with RAILS_ENV: fetch(:environment) do within release_path do execute :bundle, "install", "--without #{fetch(:bundle_without)}" end end end end end before 'deploy:updated', 'bundler:install' before 'deploy:restart', 'bundler:install' after 'deploy:updated', 'deploy:publishing' after 'deploy:restart','deploy:restart_node'
部署/ production.rb
set :stage, :production set :branch, "REPO_BRANCH" set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}" set :server_name, "XXXXXXX.com www.XXXXXXXX.com" set :password, ask('Server password', nil) server 'XXXXXX.com', user: 'XXXXXX', password: fetch(:password), port: 22, roles: %w{web app}, primary: true set :deploy_to, '/PATH/TO/APP' set :rails_env, :production set :environment, "production" set :unicorn_worker_count, 5 set :enable_ssl, false
小智.. 11
看起来capistrano在/ var/www /:appname/repo中保存了一个repo /目录,它缓存了git repo,所以如果你改变repo capistrano将不会自动更新.
Nuking repo目录对我有用
看起来capistrano在/ var/www /:appname/repo中保存了一个repo /目录,它缓存了git repo,所以如果你改变repo capistrano将不会自动更新.
Nuking repo目录对我有用