###前提・実現したいこと
デプロイしたrailsアプリをブラウザで表示したいです。
###発生している問題・エラーメッセージ
sample-bot.tk ページは機能していません sample-bot.tk では現在このリクエストを処理できません。 HTTP ERROR 500
unicorn,nginx,railsのproduction.rbに原因があるのではないかと思ったのですが、
特にエラーが出ておらずわからないのでご相談させていただきます。
なお、さくらのVPSを使用しているのですが、
二つのアプリをデプロイしています。
一つは正常に動いています。
###該当のソースコード
【sample.conf】
upstream unicorn-unix-domain-socket { server unix:/var/run/unicorn/unicorn.sock fail_timeout=0; } upstream unicorn-tcp { server 127.0.0.1; } server { ←正常に動いている方 listen 80; server_name xxx.xx.xxx.xx; ← sample-bot.tkにしても動くので、ドメインの設定ミスではないです。 root /home/anime/var/www/anime/public; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { proxy_pass http://unicorn-unix-domain-socket; } } upstream unicorn_bot { server unix:/var/run/unicorn/unicorn_bot.sock; } server { ←正常に動かない方 listen 80 default_server; server_name sample-bot.tk; root /home/anime/var/www/bot/public; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { proxy_pass http://unicorn_bot; } }
【/home/anime/bot/current/log/production.log】
・・・・省略 D, [2017-02-19T12:57:06.711747 #16938] DEBUG -- : SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20170217160352"]] D, [2017-02-19T12:57:06.719402 #16938] DEBUG -- : (7.1ms) commit transaction D, [2017-02-19T16:36:06.774419 #31765] DEBUG -- : (4.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY) D, [2017-02-19T16:36:06.780738 #31765] DEBUG -- : (2.5ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) D, [2017-02-19T16:36:06.792256 #31765] DEBUG -- : ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations" I, [2017-02-19T16:36:06.796444 #31765] INFO -- : Migrating to CreateBots (20170217160352) D, [2017-02-19T16:36:06.798632 #31765] DEBUG -- : (0.1ms) begin transaction D, [2017-02-19T16:36:06.800766 #31765] DEBUG -- : (0.4ms) CREATE TABLE "bots" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" text, "url" text, "article_id" integer, "date" date, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) D, [2017-02-19T16:36:06.801229 #31765] DEBUG -- : (0.1ms) select sqlite_version(*) D, [2017-02-19T16:36:06.802026 #31765] DEBUG -- : (0.2ms) CREATE INDEX "index_bots_on_name_and_url_and_article_id_and_date" ON "bots" ("name", "url", "article_id", "date") D, [2017-02-19T16:36:06.808601 #31765] DEBUG -- : SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20170217160352"]] D, [2017-02-19T16:36:06.812407 #31765] DEBUG -- : (3.6ms) commit transaction D, [2017-02-19T16:36:06.816470 #31765] DEBUG -- : ActiveRecord::InternalMetadata Load (0.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", :environment], ["LIMIT", 1]] D, [2017-02-19T16:36:06.821504 #31765] DEBUG -- : (0.1ms) begin transaction D, [2017-02-19T16:36:06.823190 #31765] DEBUG -- : SQL (0.2ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "production"], ["created_at", 2017-02-19 07:36:06 UTC], ["updated_at", 2017-02-19 07:36:06 UTC]] D, [2017-02-19T16:36:06.825162 #31765] DEBUG -- : (1.7ms) commit transaction
特に関連するエラーは出ていませんが。。。
【sudo tail /var/log/nginx/error.log;】
2017/02/19 16:38:37 [error] 17861#17861: *17 connect() to unix:/var/run/unicorn/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 126.129.108.242, server: xxx.xx.xxx.xx, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn/unicorn.sock:/", host: "xxx.xx.xxx.xx" 2017/02/19 16:38:37 [error] 17861#17861: *17 connect() to unix:/var/run/unicorn/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 126.129.108.242, server: xxx.xx.xxx.xx0, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/var/run/unicorn/unicorn.sock:/favicon.ico", host: "xxx.xx.xxx.xx", referrer: "http://xxx.xx.xxx.xx/" [anime@tk2-241-30026 log]$
【unicorn.rb】
worker_processes 2 working_directory "/home/anime/bot/current" listen "/var/run/unicorn/unicorn_bot.sock" pid "/var/run/unicorn/unicorn_bot.pid" preload_app true
【environments/production.rb】
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = true # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = true # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Mount Action Cable outside main process or domain # config.action_cable.mount_path = nil # config.action_cable.url = 'wss://example.com/cable' # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :debug # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment) # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "workspace_#{Rails.env}" config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end
###補足情報(言語/FW/ツール等のバージョンなど)
CentOS6.8
rails5.0
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/19 10:34