LoginSignup
8
7

More than 5 years have passed since last update.

Capistranoデプロイ後にプロセスのリビジョンを確認する(scm=git版)

Last updated at Posted at 2012-12-26

この記事は最終更新から1年以上経過しています。 気をつけてね。

Capistranoでデプロイすると、コードを設置した後に新旧コードをシンボリックリンクで入れ替える。
この方式はロールバックが簡単で良いのだが、リスタートしたつもりのプロセスは本当にCurrentのものか気になるので確認する。

revisionチェックのタスク

scmにgitを指定した際、capistranoは#{current_path}/REVISIONにコミットのハッシュを置くので、/procから実行中プロセスのワーキングディレクトリを覗く。

deploy.rb
namespace :deploy do
  task :print_revision do
    run "cat #{current_path}/REVISION"
    run "/proc/`cat #{shared_path}/pids/myapp.pid`/cwd/REVISION"
  end
end

実行サンプル

  * executing "cat /opt/deploy/myapp/current/REVISION"
 ** [out :: xx.xx.xx.xx] 7f36e97e7d4fa16b3556b0d2a2c73f86fb108871
  * executing "cat /proc/`cat /opt/deploy/myapp/shared/pids/myapp.pid`/cwd/REVISION"
 ** [out :: xx.xx.xx.xx] 7f36e97e7d4fa16b3556b0d2a2c73f86fb108871

ハッシュがあっていればよし。

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