我正在使用rails 4
nginx
和passenger
作为我的个人项目。今天我决定使用capistrano
进行部署。我的capsitrano配置工作正常,我能够将我的应用程序部署到生产中。部署后,我可以在current
文件夹和最新release
文件夹中看到我的更改。但我没有看到浏览器的变化。
假设我在设置capistrano后在服务器上有以下文件夹结构。
[1]app_name/app/views/finance/index.html
[2]app_name/releases/<latest_release>app/views/finance/index.html
[3]app_name/current/app/views/finance/index.html
如果我ssh到服务器然后I can see my code changes are applied to folder structure [2] and [3]
但我的代码没有更新文件夹结构[1]。
以下是我的上限文件的摘要:
production.rb
set :port, 22
set :user, 'deploy'
set :deploy_via, :remote_cache
set :use_sudo, false
server 'xx.xxx.x.xxx',
roles: [:web, :app, :db],
port: fetch(:port),
user: fetch(:user),
primary: true
set :deploy_to, "/var/www/app_name"
set :ssh_options, {
forward_agent: true,
auth_methods: %w(publickey),
user: 'deploy',
}
set :rails_env, :production
set :conditionally_migrate, true
deploy.rb
lock '3.4.0'
set :application, 'app_name'
set :repo_url, 'git@github.com:user_name/app_name.git'
# Default branch is :master
set :branch, 'master'
set :use_sudo, false
set :bundle_binstubs, nil
# 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 keep_releases is 5
set :keep_releases, 5
set :keep_assets, 3
namespace :deploy do
task :restart do
on roles(:app) do
within release_path do
execute :touch, 'tmp/restart.txt'
end
end
end
end
我是否需要将我的应用程序服务器指向current
目录?
答案 0 :(得分:0)
我通过告诉nginx
指向current/public
文件夹来解决问题。
root /var/www/app_name/current/public;