Capistrano/Rails 未显示最新更改

问题描述 投票:0回答:1

我将

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, '[email protected]: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
目录吗?

ruby-on-rails capistrano
1个回答
0
投票

我通过告诉

nginx
指向
current/public
文件夹解决了问题。

root /var/www/app_name/current/public;

(误删编辑)

© www.soinside.com 2019 - 2024. All rights reserved.