質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

VPS

VPS(バーチャル・プライベート・サーバ)は、仮想化されたサーバをレンタルするサービスで、共有サーバでありながら専門サーバと同等の機能を果たします。物理的な専門サーバより安価で提供できるメリットがあります。

Q&A

解決済

1回答

5527閲覧

http500エラーについて

s.k

総合スコア423

unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

VPS

VPS(バーチャル・プライベート・サーバ)は、仮想化されたサーバをレンタルするサービスで、共有サーバでありながら専門サーバと同等の機能を果たします。物理的な専門サーバより安価で提供できるメリットがあります。

0グッド

0クリップ

投稿2017/02/19 08:44

###前提・実現したいこと
デプロイしたrailsアプリをブラウザで表示したいです。

###発生している問題・エラーメッセージ

イメージ説明

該当URL

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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

構成についての説明がないので、列挙されているログからnginx⇒unicorn⇒rialsのように構成されているものと推測します。

まず、production.logについて「エラーは出ていない」とだけコメントありますが、これがログの末尾であるならば「Migrating to CreateBots (20170217160352)」で終わっているので、プログラムはアクセスされていません。プログラム実行されていないのでエラーが記録されないのは当然の結果です。
tail -f /home/anime/bot/current/log/production.log 等でログを表示しながらブラウザからアクセスれば、プログラムが実行されていないことはすぐわかるはずです。

次に、/var/log/nginx/error.logについて何のコメントもありませんが、「connect() to unix:/var/run/unicorn/unicorn.sock failed」を検索するとnginx⇒unicornの接続が出来ていないことが分かるはずです。

状況確認してから、つまづいたことろで改めて質問すればよいと思います。

投稿2017/02/19 09:40

tkmtmkt

総合スコア1800

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

s.k

2017/02/19 10:34

ありがとうございます! 接続できていないのですね( ; ; )
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問