I’m trying to understand how and when the before_symlink is run, particularly if there is a failure. Take this block:
deploy_revision "foo" do
action :deploy
deploy_to "/opt/foo"
...
symlink_before_migrate(app_symlinks.merge({
... }))
purge_before_symlink([])
create_dirs_before_symlink([])
symlinks({})
before_symlink do
current_release = release_path
bash "foo_buildout_install" do
user "foo"
cwd current_release
code <<-EOH
...
EOH
end
end
restart_command do
current_release = release_path
bash "foo_foreman_install_and_restart" do
restart foo || start foo
EOH
end
end
end
Under what conditions does the before_symlink block get run? Eg, if the build fails, then chef is re-provisioned – will it get run again? What if the symlink is created, does it ever get called again?
(I’m still learning Chef, and I don’t do ruby development, so please don’t assume I understand anything about how deploy_revision works, or the rails deployment model.)
I believe it will get run every time you ‘deploy’, which I believe happens each time you provision via Chef.
If you want to research further for yourself, find the Chef install in your Ruby gems path and look inside for
./lib/chef/provider/deploy.rbThe deploy method pretty much explains itself: