Capistrano 3 で Unicorn 再起動タスクを作成しようとしています:
まず、*unicorn_pid* 変数を設定します。
set :unicorn_pid, "#{shared_path}/tmp/pids/unicorn.pid"
次に、それを再起動タスクに渡します。
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :kill, "-USR2 `cat #{fetch(:unicorn_pid)}`" if test "[ -f #{fetch(:unicorn_pid)} ]"
within release_path do
execute :bundle, "exec unicorn -D -c config/unicorn.rb -E #{fetch(:stage)}"
end
end
end
しかし、実行すると次のようにcap production deploy:restart
表示されます。
DEBUG [f4159760] Running /usr/bin/env [ -f /var/www/shared/tmp/pids/unicorn.pid ] on dev.project.net
DEBUG [f4159760] Command: [ -f /var/www/shared/tmp/pids/unicorn.pid ]
そのため、代わりに/home/user/project/shared/
path, #{shared_path} を次のように変換します/var/www/shared/
しかし、このパスをタスクで直接指定すると、unicorn_pid 変数なしで出力に表示されます。
INFO [567856e3] Running /usr/bin/env kill -USR2 `cat /home/user/project/shared/tmp/pids/unicorn.pid` on dev.educapsule.net
DEBUG [567856e3] Command: /usr/bin/env kill -USR2 `cat /home/user/project/shared/tmp/pids/unicorn.pid`
/var/www/shared/
「カスタム」変数でパスを渡すとパスが変更されるのはなぜですか?
ありがとう。