6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Capistrano の変数を Unicorn サーバの設定で利用する

Posted at

Capistarano で環境変数を設定しconfig/unicorn.rbで参照すればいい

config/deploy.rb
set :user, do # ユーザ名を入力させる
  Capistrano::CLI.ui.ask("User: ") 
end
set :application, "ikemen"
default_environment['DEPLOY_USER'] = user
default_environment['DEPLOY_APP_NAME'] = application
config/unicorn.rb
user = ENV['DEPLOY_USER'] || 'username' # ENV['USER'] でも取れたりする...
application = ENV['DEPLOY_APP_NAME'] || 'busaiku'

root_path = "/var/www/users/#{user}/#{application}"
listen "/tmp/#{user}_#{application}_unicorn.sock"

stderr_path "#{root_path}/shared/log/unicorn.log"
stdout_path "#{root_path}/shared/log/unicorn.log"

worker_processes 2
pid "#{root_path}/shared/pids/unicorn.pid"
working_directory "#{root_path}/current"

こんな感じでサーバ側に値を渡してやる

6
6
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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?