naichi's lab

3日後の自分(他人)への書き置き

capistrano3、--traceオプションで実行するタスクを表示する

f:id:naichilab:20151223173926p:plain

capistrano3、実行するとズラズラとログが出るんだけどどのタスクを実行してるのかわかりづらい。

--trace引数をつけると表示できるみたいなので試してみた。

--trace

$ bundle exec cap production deploy --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rbenv:validate (first_time)
** Execute rbenv:validate
DEBUG [3947f3d1] Running /usr/bin/env [ -d ~/.rbenv/versions/2.2.2 ] on conohaprod
DEBUG [3947f3d1] Command: [ -d ~/.rbenv/versions/2.2.2 ]
DEBUG [3947f3d1] Finished in 0.334 seconds with exit status 0 (successful).
** Invoke rbenv:map_bins (first_time)
** Execute rbenv:map_bins
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_linked_dirs (first_time)
** Execute deploy:set_linked_dirs
** Invoke deploy:set_rails_env
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
INFO [2ca468cb] Running /usr/bin/env mkdir -p /tmp/unityroom/ on conohaprod
DEBUG [2ca468cb] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.2 /usr/bin/env mkdir -p /tmp/unityroom/ )
INFO [2ca468cb] Finished in 0.105 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/unityroom/git-ssh.sh 0.0%
INFO Uploading /tmp/unityroom/git-ssh.sh 100.0%
INFO [17c3b0ba] Running /usr/bin/env chmod +x /tmp/unityroom/git-ssh.sh on conohaprod
DEBUG [17c3b0ba] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.2 /usr/bin/env chmod +x /tmp/unityroom/git-ssh.sh )
INFO [17c3b0ba] Finished in 0.345 seconds with exit status 0 (successful).
** Execute git:check
[続く...]

**から始まる行が--traceオプションで表示されるようになった箇所ですね。

これならエラーした際にどのタスクを実行していたか簡単に確認できますね。

--dry-run と組み合わせる

$ bundle exec cap production deploy --dry-run --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rbenv:validate (first_time)
** Execute rbenv:validate
INFO [07642b31] Running /usr/bin/env [ -d ~/.rbenv/versions/2.2.2 ] on conohaprod
DEBUG [07642b31] Command: [ -d ~/.rbenv/versions/2.2.2 ]
** Invoke rbenv:map_bins (first_time)
** Execute rbenv:map_bins
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_linked_dirs (first_time)
** Execute deploy:set_linked_dirs
** Invoke deploy:set_rails_env
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
INFO [ceafd92c] Running /usr/bin/env mkdir -p /tmp/unityroom/ on conohaprod
DEBUG [ceafd92c] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.2 /usr/bin/env mkdir -p /tmp/unityroom/ )
INFO [fff4fd1a] Running /usr/bin/env #<StringIO:0x007fe03d13c778> /tmp/unityroom/git-ssh.sh on conohaprod
DEBUG [fff4fd1a] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.2 /usr/bin/env #<StringIO:0x007fe03d13c778> /tmp/unityroom/git-ssh.sh )

--dry-runも一緒につけると実際には実行せず、呼び出し順を確認することができます。

こっちも便利ですね。

参考

github.com