@@ -60,6 +60,34 @@ def run(command, &block)
6060 end
6161
6262 def action_deploy
63+ if all_releases . include? ( release_path )
64+ Chef ::Log . info ( "Already deployed app at #{ release_path } , skipping. Use action :force_deploy to force." )
65+ else
66+ deploy
67+ end
68+ end
69+
70+ def action_force_deploy
71+ if all_releases . include? ( release_path )
72+ Chef ::Log . info ( "Already deployed app at #{ release_path } , forcing." )
73+ FileUtils . rm_rf ( release_path )
74+ end
75+ deploy
76+ end
77+
78+ def action_rollback
79+ @release_path = all_releases [ -2 ]
80+ raise RuntimeError , "There is no release to rollback to!" unless @release_path
81+ release_to_nuke = all_releases . last
82+ Chef ::Log . info "rolling back to previous release: #{ release_path } "
83+ symlink
84+ Chef ::Log . info "removing last release: #{ release_to_nuke } "
85+ FileUtils . rm_rf release_to_nuke
86+ Chef ::Log . info "restarting with previous release"
87+ restart
88+ end
89+
90+ def deploy
6391 Chef ::Log . info "deploying branch: #{ @new_resource . branch } "
6492 enforce_ownership
6593 update_cached_repo
@@ -76,18 +104,6 @@ def action_deploy
76104 cleanup!
77105 end
78106
79- def action_rollback
80- @release_path = all_releases [ -2 ]
81- raise RuntimeError , "There is no release to rollback to!" unless @release_path
82- release_to_nuke = all_releases . last
83- Chef ::Log . info "rolling back to previous release: #{ release_path } "
84- symlink
85- Chef ::Log . info "removing last release: #{ release_to_nuke } "
86- FileUtils . rm_rf release_to_nuke
87- Chef ::Log . info "restarting with previous release"
88- restart
89- end
90-
91107 def callback ( what , callback_code = nil )
92108 @collection = Chef ::ResourceCollection . new
93109 case callback_code
@@ -162,8 +178,8 @@ def update_cached_repo
162178 def copy_cached_repo
163179 Chef ::Log . info "copying the cached checkout to #{ release_path } "
164180 FileUtils . mkdir_p ( @new_resource . deploy_to + "/releases" )
165- FileUtils . cp_r ( @new_resource . destination , release_path , :preserve => true )
166- release_created
181+ FileUtils . cp_r ( " #{ @new_resource . destination } ." , release_path , :preserve => true )
182+ release_created ( release_path )
167183 end
168184
169185 def enforce_ownership
@@ -213,7 +229,7 @@ def purge_tempfiles_from_current_release
213229
214230 # Internal callback, called after copy_cached_repo.
215231 # Override if you need to keep state externally.
216- def release_created
232+ def release_created ( release_path )
217233 end
218234
219235 # Internal callback, called during cleanup! for each old release removed.
0 commit comments