Nginx Proxied to Unicorn¶ ↑ Nginx and Unicorn combine to provide a very powerful setup for deploying your Sinatra applications. This guide will show you how to effectively setup this combination for deployment. Installation¶ ↑ First thing you will need to do is get nginx installed on your system. This should be handled by your operating systems package manager. For more information on installing n
# -*- coding: utf-8 -*- # ワーカーの数 worker_processes 2 # ソケット listen '/tmp/unicorn.sock' pid '/tmp/unicorn.pid' # ログ log = '${my_app}/log/unicorn.log' stderr_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT']) stdout_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT']) preload_app true GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true before_fork do |server,
構築を試みたときに調べたことなどなど なぜunicorn + nginx? unicornは汎用のRackアプリケーションサーバ。Railsからもsinatraからも使える。 unicornだけでも、任意のポートをlistenすればwebサーバーとして使えるが、 以下のようなメリットがあるため、本番ではnginxをリバースプロキシとして 前に立ててからリクエストをunicornに流すのが良い 画像やcssなどの静的ファイルはnginxで高速に返せる リクエストをバッファリングして受信完了してからunicornにリクエストを 投げるため、遅い回線(3Gなど)で接続が来た時にunicornの ワーカプロセスの待ち時間を削減できる 動作原理はgithubの運用例が記載された以下のドキュメントが詳しい https://github.com/blog/517-unicorn まずは、unicornだ
そもそも Sinatraは「Webアプリケーションフレームワーク」として Unicornは「アプリケーションサーバー」として Nginxを「リバースプロキシ」として それぞれ必要である。Sinatra単体でもWebサーバーとして機能はするけどデーモン化できないので運用ができない。Supervisorで強制的にデーモン化という手もあるみたいだけど後々を考えてリバースプロキシにしてみた Sinatra+Unicornを構成 まずはNginx抜きでSinatra+Unicornを構成してみる。RubyとGem自体はインストールが終了しているとする。 Unicornのインストール(bundle抜き) gem install unicorn 特に初期設定はなし Hello Worldを出してみる bundle initでGemfileを生成 Gemfileを以下のようにする source "http
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く