我已经将Rails应用程序部署到生产环境中,但是为什么它仍使用环境暂存,我的Rails应用程序仍连接到暂存数据库,链接URL仍转发至暂存应用程序,例如电子邮件确认它应连接至生产应用程序。
我正在使用capistrano,puma和我的服务器使用nginx进行部署
是否缺少某些内容?
这是database.yml代码
development:
encoding: utf8mb4
collation: utf8mb4_unicode_ci
adapter: mysql2
database: database_development
pool: 5
username: root
password: 123456
staging:
host: 127.0.0.1
encoding: utf8mb4
collation: utf8mb4_unicode_ci
adapter: mysql2
database: database_staging
pool: 8
username: root
password: <%= ENV['RAILS_DB_PW'] %>
test:
encoding: utf8mb4
collation: utf8mb4_unicode_ci
adapter: mysql2
database: database_test
pool: 5
username: root
password: 123456
production:
encoding: utf8mb4
collation: utf8mb4_unicode_ci
adapter: mysql2
database: database_production
pool: 60
username: root
password: <%= ENV['RAILS_DB_PW'] %>
这是production.rb代码
set :application, 'my rails app'
set :stage, :production
set :rails_env, 'production'
set :deploy_to, "/var/#{fetch(:user)}/#{fetch(:application)}"
set :server_name, "my-rails-app.com"
set :delayed_job_args, "-n 4"
# http://stackoverflow.com/questions/21036175/how-to-deploy-a-specific-revision-with-capistrano-3
set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || 'master'
role :app, %w{deploy@1.2.3.4}
role :web, %w{deploy@1.2.3.4}
role :db, %w{deploy@1.2.3.4}
server '1.2.3.4', user: 'deploy', roles: %w{web app}
这是deploy.rb代码
lock "~> 3.11.0"
set :application, "my-rails-app"
set :repo_url, "git@github.com:user/my-rails-app.git"
set :user, 'deploy'
set :puma_env, 'staging'
set :puma_threads, [1, 16]
set :puma_workers, 1
set :rvm_ruby_version, '2.4.1'
set :ssh_options, { forward_agent: true, auth_methods: %w(publickey) }
set :deploy_via, :remote_cache
set :ssh_options, { forward_agent: true, auth_methods: %w(publickey) }
set :linked_files, %w{.env config/master.key config/database.yml}
set :linked_dirs, %w{log tmp/cache tmp/sockets tmp/export tmp/pids public/assets public/uploads config/locales/field_translation/medical_category}
SSHKit.config.command_map[:rake] = 'bundle exec rake'
SSHKit.config.command_map[:runner] = 'bundle exec rails runner'
SSHKit.config.command_map[:sidekiq] = "bundle exec sidekiq"
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, :restart
desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
invoke 'deploy'
end
end
end
谢谢??
答案 0 :(得分:0)
在deploy.rb中添加
"MOTOR DC 1 250"
答案 1 :(得分:0)
我没有使用这些工具的经验,但是当您使用ShapeDrawable
时,是否可以检查是否存在名为set :rails_env, 'production'
而不是RAILS_ENV
的环境变量?因为Rails需要一个名为rails_env
的环境变量。
答案 2 :(得分:0)
应归因于puma_env。您已将puma_env设置为deploy.rb中的登台。 在production.rb中,应将其设置为以下生产
set :puma_env, 'production'
答案 3 :(得分:0)
就我而言,我必须跑步:
cap production puma:config