我为capistrano配置设置了以下文件。当我使用以下命令部署项目时,它将部署到服务器,但Rails.env
设置为“部署”。如何将其正确设置为“生产”?
部署命令
cap production deploy
deploy.rb
set :application, 'project'
set :repo_url, 'git@github.com:AccountName/project.git'
set :deploy_to, '/home/deploy/project'
set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, 'deploy:restart'
after :finishing, 'deploy:cleanup'
end
配置/部署/ production.rb
set :stage, :production
set :branch, 'master'
set :rails_env, 'production'
server '127.0.0.1:4400', user: 'deploy', roles: %w{web app}
nginx.conf
server {
listen 80;
server_name ip_address;
rails_env production;
root /path/to/app/public;
passenger_enabled on;
}
站点可用/项目
server {
listen 80 default_server;
server_name ip_address;
passenger_enabled on;
root /path/to/app/public;
}
答案 0 :(得分:0)
问题在于passenger_app_env正在开发中。我无法弄清楚哪些服务没有重新启动,所以我重新启动了服务器。其中提出了一些其他问题,但我相当确定通过将该变量更改为passenger_app_env production
来解决问题。谢谢你的帮助!