フォルダ構成
├── Gemfile ├── Gemfile.lock ├── config.ru ├── log │ ├── unicorn.stderr.log │ └── unicorn.stdout.log ├── myapp.rb ├── tmp │ ├── pids │ │ └── unicorn.pid │ └── sockets │ └── unicorn.sock └── unicorn.rb
confing.ru
1 require "rubygems" 2 require "sinatra" ## 必要なさそう.. 3 4 require File.expand_path '../myapp.rb', __FILE__ 5 6 run Sinatra::Application
unicorn.rb
1 # set path to app that will be used to configure unicorn, 2 # note the trailing slash in this example 3 @dir = "/path/your/dir" 4 5 worker_processes 2 6 working_directory @dir 7 8 timeout 30 9 10 # Specify path to socket unicorn listens to, 11 # we will use this in our nginx.conf later 12 listen "#{@dir}tmp/sockets/unicorn.sock", :backlog => 64 13 14 # Set process id path 15 pid "#{@dir}tmp/pids/unicorn.pid" 16 17 # Set log file paths 18 stderr_path "#{@dir}log/unicorn.stderr.log" 19 stdout_path "#{@dir}log/unicorn.stdout.log"
デーモン化してアプリケーションを起動
bundle exec unicorn -c unicorn.rb -E production -D
参考リンク