Capistranoであえて非並列にコマンド実行する
システム管理系でCapistranoを使おうとする、なんでもかんでも同時並列実行されると困るというようなことがなくもない。ちょっと考えてみたんだけど、どんなものだろうか。もう少しなんとかなりそうな気もする。
def serialize_for_hosts
task = current_task
hosts = find_servers_for_task(task)
if task.options.include?(:hosts)
save_hosts = task.options[:hosts]
end
begin
hosts.each do |host|
task.options[:hosts] = [host]
yield
end
ensure
task.options[:hosts] = save_hosts if defined?(save_hosts)
end
end
task :bar do
run "echo bar"
end
task :foo do
run "echo foo start"
serialize_for_hosts do
run "sleep 2"
run "echo date"
hogehoge
end
run "echo foo end"
end
某メモより。
トラックバック
トラックバックリンク:
http://arika.org/diary/trackbacks?article_id=2530

