RailsアプリケーションをCapistranoデプロイしたのですが、We're sorry, but something went wrong.
エラー(502)となってしまい、ログを確認しようと、/var/www/RailsApp/shared/log
を確認したのですが
- ngnix.access.log
- nginx.error.log
- production.log
- unicorn_.stderr.log
にはそれっぽいログが見つからず、Railsのログの出力先が設定されていないかと思うのですが、出力させるにはどのように設定すれば良いでしょうか?
各種ファイルの設定は以下の通りです。ご回答よろしくお願いします。
config/deproy.rb
ruby
1lock "~> 3.10.2" 2 3set :application, "アプリケーション名" 4set :repo_url, "git@github.com:〇〇/〇〇.git" 5 6 set :deploy_to, '/var/www/RailsApp' 7 8 set :default_env, { 9 :DEVISE_SECRET_KEY => ENV['DEVISE_SECRET_KEY'] 10} 11 12set :format_options, truncate: false 13 14append :linked_files, "config/database.yml" 15 16set :linked_files, %w{config/database.yml config/secrets.yml} 17set :linked_dirs, %w{bin log tmp/pids tmp/cache sockets bundle public/system public/assets} 18set :unicorn_pid, "#{shared_path}/tmp/pids/unicorn.pid" 19 20set :ssh_options, { verify_host_key: :secure, forward_agent: true } 21set :rbenv_type, :user 22set :rbenv_ruby, '2.5.1' 23set :rbenv_path, '/usr/local/rbenv' 24set :log_level, :debug 25 26after 'deploy:publishing', 'deploy:restart' 27namespace :deploy do 28 task :restart do 29 on roles(:app) do 30 within current_path do 31 if test("[ -e #{fetch(:unicorn_pid)} ]") 32 execute :kill, "-s QUIT ", pid 33 end 34 secret = capture :bundle, "exec rake secret" 35 execute "echo SECRET_KEY_BASE='#{secret}' > #{current_path}/.env" 36 execute :bundle, "exec unicorn", "-c", fetch(:unicorn_config_path), "-E", fetch(:rails_env), "-D" 37 end 38 end 39 end 40end
production.rb
ruby
1Rails.application.configure do 2 config.cache_classes = true 3 config.eager_load = true 4 config.consider_all_requests_local = false 5 config.action_controller.perform_caching = true 6 config.public_file_server.enabled = true 7 config.assets.js_compressor = :uglifier 8 config.assets.compile = false 9 10 config.log_level = :debug 11 config.log_tags = [ :request_id ] 12 config.action_mailer.perform_caching = false 13 config.i18n.fallbacks = true 14 config.active_support.deprecation = :notify 15 config.log_formatter = ::Logger::Formatter.new 16 17 if ENV["RAILS_LOG_TO_STDOUT"].present? 18 logger = ActiveSupport::Logger.new(STDOUT) 19 logger.formatter = config.log_formatter 20 config.logger = ActiveSupport::TaggedLogging.new(logger) 21 end 22 23 config.active_record.dump_schema_after_migration = false 24 config.assets.precompile += ['*.js'] 25end
unicorn.rb
ruby
1rails_root = File.expand_path('../../../', __FILE__) 2 3ENV['BUNDLE_GEMFILE'] = rails_root + "/Gemfile" 4 5worker_processes 2 6timeout 30 7preload_app true 8 9stderr_path File.expand_path('../../../../log/unicorn_stderr.log', __FILE__) 10 11listen "#{rails_root}/tmp/unicorn.sock" 12app_path = File.expand_path('../../../', __FILE__) 13shared_path = File.expand_path('../../../../shared/', __FILE__) 14 15before_fork do |server, worker| 16 defined?(ActiveRecord::Base) and 17 ActiveRecord::Base.connection.disconnect! 18 19 old_pid = "#{server.config[:pid]}.oldbin" 20 if old_pid != server.pid 21 begin 22 sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU 23 Process.kill(sig, File.read(old_pid).to_i) 24 rescue Errno::ENOENT, Errno::ESRCH 25 end 26 end 27end 28 29after_fork do |server, worker| 30 defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection 31end 32
環境
CentOS7
Nignx
unicorn
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。