LoginSignup
11
9

More than 5 years have passed since last update.

capistrano3-unicorn使う時はちゃんとドキュメントとコードを読む

Posted at

cap3付近、DSL祭りなので初期値や設定可能な値など毎回ソースみて確認する必要ある。

んで、ちゃんとコードとドキュメントを読めば
何も困ることはないという当たり前のことを学んだので忘れないうちにメモ

Capfile

require 'capistrano3/unicorn'

Gemfile

gem 'unicorn'

で使えるようにして

cap production unicorn:startをしてもうんともすんとも言わんということになったが :tired_face:

そもそも

unicorn.rake

namespace :load do
  task :defaults do
    set :unicorn_pid, -> { File.join(current_path, "tmp", "pids", "unicorn.pid") }
    set :unicorn_config_path, -> { File.join(current_path, "config", "unicorn", "#{fetch(:rails_env)}.rb") }
    set :unicorn_roles, -> { :app }
    set :unicorn_options, -> { "" }
    set :unicorn_rack_env, -> { fetch(:rails_env) == "development" ? "development" : "deployment" }
    set :unicorn_restart_sleep_time, 3
  end
end

unicorn_rolesはデフォルトでappが指定されている

ので README.md

You can override the defaults by set :unicorn_example, value in the config/deploy.rb or config/deploy/ENVIRONMENT.rb capistrano deployment files.

って書いてあるので

set :unicorn_roles, "hoge"みたいな設定をconfig/deploy.rbconfig/deploy/ENV.rbに書く

ちなみに

current_path/tmp/pids/unicorn.pidみたいなものは

deploy.rb のテンプレート

この辺に書いてあって
cap installした時に生成されるconfig/deploy.rbにコメントアウトで記述されているので
コメントアウトを解除すればよしなに作成してくれるので自分でつくる必要はない。
カスタマイズしたければこの辺をよしなにする。

READMEちゃんと読んでコードで確認すれば一瞬でわかることに無駄にはまった。
基本大切にしていこう :pray:

11
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
9