Skip to content

Commit

Permalink
Introduced cli.show_status to reduce code duplication
Browse files Browse the repository at this point in the history
Fixed deployment_state.transaction_getter to include deployment_copy or
deployment_local_build in every config - so that fast_rollback can work
(the problem was that prepare_build or prepare_deployment were not
called before the fast_rollback).
Minor changes
  • Loading branch information
mbushkov committed Aug 28, 2011
1 parent 9d8e2d8 commit 8b0a27f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 34 deletions.
8 changes: 1 addition & 7 deletions lib/robert/deployment/ext/build.rb
Expand Up @@ -27,13 +27,7 @@
end
end

begin
call_next
logi("build OK")
rescue => e
loge("build FAILED: #{e}")
raise e
end
call_next
}
end

59 changes: 39 additions & 20 deletions lib/robert/deployment/ext/cli.rb
Expand Up @@ -40,9 +40,12 @@
$top.conf(dep.name) do
include "area:#{area.name}"
act[:revision] = revision.explicit { var[:revision] = dep.revision }

#NOTE: A bit of a hack since this action is also executedin prepare_build/prepare_deployment
include (area.name == "local" ? :deployment_local_build : :deployment_copy)
end
end

conf = $top.cclone(dep.name)
end

Expand Down Expand Up @@ -86,6 +89,10 @@
}
end

defn cli.prepare_build_or_deployment do

end

defn cli.fast_rollback do
body {
deployment_state = $top.cclone(:deployment_state)
Expand All @@ -109,14 +116,19 @@
area.current_snapshot.save!

area.current_snapshot = snapshot

begin
Robert::Deployment::SnapshotTransactionCleaner.new(deployment_state.transaction_getter).clean_unfinished_snapshot(area)
logi("fast rollback OK")
rescue => e
logi("fast rollback failed: #{e}")
raise e
end
Robert::Deployment::SnapshotTransactionCleaner.new(deployment_state.transaction_getter).clean_unfinished_snapshot(area)
end
}
end

defn cli.show_status do
body {
begin
call_next
logi("#{var[:message]} OK")
rescue => e
logi("#{var[:message]} FAILED: #{e}")
raise e
end
}
end
Expand All @@ -126,22 +138,29 @@
act[:deploy] = deployment_db.with_connection(
deployment_db.migrate(
cli.prepare_deployment(
confs_to_deploy.from_cmdline(
confs_to_deploy.with_runtime_deps(
# confs_to_deploy.remote_fresh_only(
confs_to_deploy.order_by_runtime_deps(
cli.deploy))))))#)
cli.show_status(
confs_to_deploy.from_cmdline(
confs_to_deploy.with_runtime_deps(
# confs_to_deploy.remote_fresh_only(
confs_to_deploy.order_by_runtime_deps(
cli.deploy)))))))
var[:deploy,:*,:show_status,:message] = "deployment"

var[:prepare_build,:deployment,:area] = :local
act[:build] = deployment_db.with_connection(
deployment_db.migrate(
cli.prepare_build(
confs_to_deploy.from_cmdline(
confs_to_deploy.local_fresh_only(
confs_to_deploy.with_runtime_deps(
confs_to_deploy.order_by_runtime_deps(
cli.deploy)))))))
cli.show_status(
confs_to_deploy.from_cmdline(
confs_to_deploy.local_fresh_only(
confs_to_deploy.with_runtime_deps(
confs_to_deploy.order_by_runtime_deps(
cli.deploy))))))))
var[:build,:*,:show_status,:message] = "build"

act[:fast_rollback] = deployment_db.with_connection(
deployment_db.migrate(
cli.fast_rollback))
cli.show_status(
cli.fast_rollback)))
var[:fast_rollback,:*,:show_status,:message] = "fast rollback"
end
8 changes: 1 addition & 7 deletions lib/robert/deployment/ext/deploy.rb
Expand Up @@ -9,13 +9,7 @@
include :deployment_copy
end

begin
call_next
logi("deployment OK")
rescue => e
loge("deployment FAILED: #{e}");
raise e
end
call_next
}
end

0 comments on commit 8b0a27f

Please sign in to comment.