Bugs: Browse | Submit New | Admin

[#13074] update and symlink should be separate tasks

Date:
2007-08-14 22:13
Priority:
4
Submitted By:
Joshua Sierles (jsierles)
Assigned To:
John Barnette (jbarnette)
Category:
vlad
State:
Open
Summary:
update and symlink should be separate tasks

Detailed description
The source update and release symlink tasks should be separate, since a very common deployment task is linking in or
packaging assets (such as the new Rails asset packager) after updating the code, but before symlinking. Without this
separation, a race condition exists that could leave assets unavailable for a short period.

+1 for more modularity in general with default deploy recipes.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2011-06-03 05:38
Sender: s b

See the following example which, replicates the race condition
invoking remote rake tasks with multiple hosts. Similar to the
update task in in core.rb.

Using vlad (2.2.0)

-- deploy.rb --
role :app, [ "host1", "host2" ]
set :file, "/tmp/foo.txt"

def touch_file
  run "echo touching file  #{file} on `hostname`"
  run "if [ `hostname` = \"host2\" ]; then sleep
10; fi"
  run "touch #{file}"
  run "echo touched file  #{file} on on `hostname`"
end

def test_file
  run "echo testing file #{file} on `hostname`"
  run "if [ ! -e  #{file} ]; then exit 1; fi"
  run "echo file #{file} exists on `hostname`"
end

namespace :remote_deps do
  task :default => :test_file

  remote_task :touch_file, {:needs => :clean}, :roles =>
:app do
    touch_file
  end

  remote_task :test_file, {:needs => :touch_file}, :roles
=> :app  do
    test_file
  end
end

namespace :remote_invoke do
  task :default => :touch_file
  
  remote_task :touch_file, {:needs => :clean}, :roles =>
:app do
    touch_file
    Rake::Task['remote_invoke:test_file'].invoke
  end

  remote_task :test_file, :roles => :app  do
    test_file
  end
end

remote_task :clean, :roles => :app  do
  run "rm -f /tmp/foo.txt"
end
-- end deploy.rb --

Running 'remote_invoke:default' results in an error:

$ rake remote_invoke:default
touching file /tmp/foo.txt on host1
touching file /tmp/foo.txt on host2
touched file /tmp/foo.txt on on host1
testing file /tmp/foo.txt on host2
testing file /tmp/foo.txt on host1
file /tmp/foo.txt exists on host1
touched file /tmp/foo.txt on on host2
rake aborted!
execution failed with status 1: ssh host2.local if [ ! -e
/tmp/foo.txt ]; then exit 1; fi

--

If we use remote task dependencies over remote task invocation
the deployment runs successfully:

$ rake remote_deps:default
touching file /tmp/foo.txt on host1
touching file /tmp/foo.txt on host2
touched file /tmp/foo.txt on on host1
touched file /tmp/foo.txt on on host2
testing file /tmp/foo.txt on host1
testing file /tmp/foo.txt on host2
file /tmp/foo.txt exists on host2
file /tmp/foo.txt exists on host1
Date: 2009-05-29 19:50
Sender: Aaron Suggs

+1 for this too.

I added a patch at http://github.com/ktheory/vlad/commit/3d5ea627
5ddac3b742140b27a486a7f3ab5356ef

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
assigned_tozenspider2009-05-11 21:41zenspider
priority32009-03-05 23:59zenspider
category_idNone2007-08-22 04:05zenspider
assigned_tonone2007-08-22 04:05zenspider