Skip to content

Commit

Permalink
Fixed some issues with failing worker jobs and improved deploy receipt.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Sep 3, 2012
1 parent 36ed569 commit d1d8311
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
3 changes: 2 additions & 1 deletion bricks/passenger/zena/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
c_file = File.read("#{Zena::ROOT}/vendor/apache2_upload_progress/mod_upload_progress.c")
run "test -e #{tmp_dir} || mkdir #{tmp_dir}"
put c_file, "#{tmp_dir}/mod_upload_progress.c"
run "cd #{tmp_dir} && apxs2 -c -i mod_upload_progress.c && rm -rf #{tmp_dir}"
run "cd #{tmp_dir} && apxs2 -c -i -a mod_upload_progress.c && rm -rf #{tmp_dir}"
run apache2_reload_cmd
end
end

Expand Down
7 changes: 4 additions & 3 deletions lib/zafu/ordered_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Zafu

if RUBY_VERSION.split('.')[0..1].join('.').to_f > 1.8
OrderedHash = Hash
else
elsif !defined?(OrderedHash)
class OrderedHash < Hash

def []=(k, v)
Expand All @@ -22,8 +22,9 @@ def merge(hash)
res.merge!(hash)
res
end

alias o_keys keys

def get_keys
@keys ||= o_keys
end
Expand All @@ -33,7 +34,7 @@ def keys
end

def each
keys.each do |k|
get_keys.each do |k|
yield(k, self[k])
end
end
Expand Down
36 changes: 19 additions & 17 deletions lib/zena/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,6 @@ def create(attrs)
secure(Node) { Node.create_node(Node.transform_attributes(attrs)) }
end

def rename_prop(list, old_key, new_key)
list = find(list) if list.kind_of?(String)
if list.first.kind_of?(Node)
list = list.map(&:visible_versions).flatten
end

list.each do |rec|
prop = rec.prop
value = prop.delete(old_key)
if !value.blank?
prop[new_key] = value
Zena::Db.execute "UPDATE #{rec.class.table_name} SET properties=#{Zena::Db.quote(rec.class.encode_properties(prop))} WHERE id=#{rec[:id]}"
end
end
"Renamed '#{old_key}' to '#{new_key}' in #{list.size} #{list.first.class.to_s.downcase.pluralize}"
end

def field_to_prop(list, native_key, prop_key)
list = find(list) if list.kind_of?(String)
list.each do |rec|
Expand Down Expand Up @@ -70,15 +53,33 @@ def set_prop(list, key, value)
end
end

def rename_prop(pseudo_sql, old_key, new_key)
count = 0
foreach(pseudo_sql) do |node|
node.versions.each do |rec|
count += 1
prop = rec.prop
value = prop.delete(old_key)
if !value.blank?
prop[new_key] = value
Zena::Db.execute "UPDATE #{rec.class.table_name} SET properties=#{Zena::Db.quote(rec.class.encode_properties(prop))} WHERE id=#{rec[:id]}"
end
end
end
"Renamed '#{old_key}' to '#{new_key}' in #{count} versions"
end

# Transform every value of a given property by using a block with |node, old_value| and
# returning the new value.
def change_prop(pseudo_sql, key)
count = 0
unless block_given?
puts "You need to provide a block |node, old_value| and return the new value"
return
end
foreach(pseudo_sql) do |node|
node.versions.each do |v|
count += 1
prop = v.prop
val = prop[key]
new_val = yield(node, val)
Expand All @@ -92,6 +93,7 @@ def change_prop(pseudo_sql, key)
end
end
end
"Changed '#{key}' prop in #{count} versions"
end

def login(name, host = nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/zena/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def ancestry(path)

run "test -e /etc/apache2/sites-enabled/000-default && a2dissite default || echo 'default already disabled'"

modules = %w{rewrite deflate proxy_balancer proxy proxy_http expires}
modules = %w{rewrite headers deflate proxy_balancer proxy proxy_http expires}
if self[:ssl]
modules << 'ssl'
modules << 'headers'
Expand Down
9 changes: 8 additions & 1 deletion lib/zena/site_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ def perform(site = nil)
Zena::SiteWorker.perform(site, action, page + 1)

# do action on nodes
site.send(action, nodes, page, page_count)
begin
site.send(action, nodes, page, page_count)
rescue => err
# If we let the action fail, it will rerun and we will recreate an action for page + 1 !
Site.logger.warn "[JOB] Failed: '#{action}'"
Site.logger.warn err.message
end

end
end
end
Expand Down

0 comments on commit d1d8311

Please sign in to comment.